1 /* DirectShow FilterGraph object (QUARTZ.DLL)
3 * Copyright 2002 Lionel Ulmer
4 * Copyright 2004 Christian Costa
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include "quartz_private.h"
24 HWND hWnd
; /* Target window */
25 UINT msg
; /* User window message */
26 LONG_PTR instance
; /* User data */
27 int disabled
; /* Disabled messages posting */
31 LONG lEventCode
; /* Event code */
32 LONG_PTR lParam1
; /* Param1 */
33 LONG_PTR lParam2
; /* Param2 */
36 /* messages ring implementation for queuing events (taken from winmm) */
37 #define EVENTS_RING_BUFFER_INCREMENT 64
43 CRITICAL_SECTION msg_crst
;
44 HANDLE msg_event
; /* Signaled for no empty queue */
47 static int EventsQueue_Init(EventsQueue
* omr
)
51 omr
->msg_event
= CreateEventW(NULL
, TRUE
, FALSE
, NULL
);
52 omr
->ring_buffer_size
= EVENTS_RING_BUFFER_INCREMENT
;
53 omr
->messages
= CoTaskMemAlloc(omr
->ring_buffer_size
* sizeof(Event
));
54 ZeroMemory(omr
->messages
, omr
->ring_buffer_size
* sizeof(Event
));
56 InitializeCriticalSection(&omr
->msg_crst
);
57 omr
->msg_crst
.DebugInfo
->Spare
[0] = (DWORD_PTR
)(__FILE__
": EventsQueue.msg_crst");
61 static int EventsQueue_Destroy(EventsQueue
* omr
)
63 CloseHandle(omr
->msg_event
);
64 CoTaskMemFree(omr
->messages
);
65 omr
->msg_crst
.DebugInfo
->Spare
[0] = 0;
66 DeleteCriticalSection(&omr
->msg_crst
);
70 static BOOL
EventsQueue_PutEvent(EventsQueue
* omr
, const Event
* evt
)
72 EnterCriticalSection(&omr
->msg_crst
);
73 if (omr
->msg_toget
== ((omr
->msg_tosave
+ 1) % omr
->ring_buffer_size
))
75 int old_ring_buffer_size
= omr
->ring_buffer_size
;
76 omr
->ring_buffer_size
+= EVENTS_RING_BUFFER_INCREMENT
;
77 TRACE("omr->ring_buffer_size=%d\n",omr
->ring_buffer_size
);
78 omr
->messages
= CoTaskMemRealloc(omr
->messages
, omr
->ring_buffer_size
* sizeof(Event
));
79 /* Now we need to rearrange the ring buffer so that the new
80 buffers just allocated are in between omr->msg_tosave and
83 if (omr
->msg_tosave
< omr
->msg_toget
)
85 memmove(&(omr
->messages
[omr
->msg_toget
+ EVENTS_RING_BUFFER_INCREMENT
]),
86 &(omr
->messages
[omr
->msg_toget
]),
87 sizeof(Event
)*(old_ring_buffer_size
- omr
->msg_toget
)
89 omr
->msg_toget
+= EVENTS_RING_BUFFER_INCREMENT
;
92 omr
->messages
[omr
->msg_tosave
] = *evt
;
93 SetEvent(omr
->msg_event
);
94 omr
->msg_tosave
= (omr
->msg_tosave
+ 1) % omr
->ring_buffer_size
;
95 LeaveCriticalSection(&omr
->msg_crst
);
99 static BOOL
EventsQueue_GetEvent(EventsQueue
* omr
, Event
* evt
, LONG msTimeOut
)
101 if (WaitForSingleObject(omr
->msg_event
, msTimeOut
) != WAIT_OBJECT_0
)
104 EnterCriticalSection(&omr
->msg_crst
);
106 if (omr
->msg_toget
== omr
->msg_tosave
) /* buffer empty ? */
108 LeaveCriticalSection(&omr
->msg_crst
);
112 *evt
= omr
->messages
[omr
->msg_toget
];
113 omr
->msg_toget
= (omr
->msg_toget
+ 1) % omr
->ring_buffer_size
;
115 /* Mark the buffer as empty if needed */
116 if (omr
->msg_toget
== omr
->msg_tosave
) /* buffer empty ? */
117 ResetEvent(omr
->msg_event
);
119 LeaveCriticalSection(&omr
->msg_crst
);
123 #define MAX_ITF_CACHE_ENTRIES 3
124 typedef struct _ITF_CACHE_ENTRY
{
130 typedef struct _IFilterGraphImpl
{
131 IUnknown IUnknown_inner
;
132 IFilterGraph2 IFilterGraph2_iface
;
133 IMediaControl IMediaControl_iface
;
134 IMediaSeeking IMediaSeeking_iface
;
135 IBasicAudio IBasicAudio_iface
;
136 IBasicVideo2 IBasicVideo2_iface
;
137 IVideoWindow IVideoWindow_iface
;
138 IMediaEventEx IMediaEventEx_iface
;
139 IMediaFilter IMediaFilter_iface
;
140 IMediaEventSink IMediaEventSink_iface
;
141 IGraphConfig IGraphConfig_iface
;
142 IMediaPosition IMediaPosition_iface
;
143 IObjectWithSite IObjectWithSite_iface
;
144 IGraphVersion IGraphVersion_iface
;
145 /* IAMGraphStreams */
150 /* IRegisterServiceProvider */
151 /* IResourceMananger */
152 /* IServiceProvider */
153 /* IVideoFrameStep */
157 IUnknown
*punkFilterMapper2
;
158 IFilterMapper2
* pFilterMapper2
;
159 IBaseFilter
** ppFiltersInGraph
;
160 LPWSTR
* pFilterNames
;
164 IReferenceClock
*refClock
;
165 IBaseFilter
*refClockProvider
;
167 HANDLE hEventCompletion
;
168 int CompletionStatus
;
172 int HandleEcComplete
;
174 int HandleEcClockChanged
;
177 ITF_CACHE_ENTRY ItfCacheEntries
[MAX_ITF_CACHE_ENTRIES
];
178 int nItfCacheEntries
;
181 REFERENCE_TIME start_time
;
182 REFERENCE_TIME pause_time
;
188 static inline IFilterGraphImpl
*impl_from_IUnknown(IUnknown
*iface
)
190 return CONTAINING_RECORD(iface
, IFilterGraphImpl
, IUnknown_inner
);
193 static HRESULT WINAPI
FilterGraphInner_QueryInterface(IUnknown
*iface
, REFIID riid
, void **ppvObj
)
195 IFilterGraphImpl
*This
= impl_from_IUnknown(iface
);
196 TRACE("(%p)->(%s (%p), %p)\n", This
, debugstr_guid(riid
), riid
, ppvObj
);
198 if (IsEqualGUID(&IID_IUnknown
, riid
)) {
199 *ppvObj
= &This
->IUnknown_inner
;
200 TRACE(" returning IUnknown interface (%p)\n", *ppvObj
);
201 } else if (IsEqualGUID(&IID_IFilterGraph
, riid
) ||
202 IsEqualGUID(&IID_IFilterGraph2
, riid
) ||
203 IsEqualGUID(&IID_IGraphBuilder
, riid
)) {
204 *ppvObj
= &This
->IFilterGraph2_iface
;
205 TRACE(" returning IGraphBuilder interface (%p)\n", *ppvObj
);
206 } else if (IsEqualGUID(&IID_IMediaControl
, riid
)) {
207 *ppvObj
= &This
->IMediaControl_iface
;
208 TRACE(" returning IMediaControl interface (%p)\n", *ppvObj
);
209 } else if (IsEqualGUID(&IID_IMediaSeeking
, riid
)) {
210 *ppvObj
= &This
->IMediaSeeking_iface
;
211 TRACE(" returning IMediaSeeking interface (%p)\n", *ppvObj
);
212 } else if (IsEqualGUID(&IID_IBasicAudio
, riid
)) {
213 *ppvObj
= &This
->IBasicAudio_iface
;
214 TRACE(" returning IBasicAudio interface (%p)\n", *ppvObj
);
215 } else if (IsEqualGUID(&IID_IBasicVideo
, riid
) ||
216 IsEqualGUID(&IID_IBasicVideo2
, riid
)) {
217 *ppvObj
= &This
->IBasicVideo2_iface
;
218 TRACE(" returning IBasicVideo2 interface (%p)\n", *ppvObj
);
219 } else if (IsEqualGUID(&IID_IVideoWindow
, riid
)) {
220 *ppvObj
= &This
->IVideoWindow_iface
;
221 TRACE(" returning IVideoWindow interface (%p)\n", *ppvObj
);
222 } else if (IsEqualGUID(&IID_IMediaEvent
, riid
) ||
223 IsEqualGUID(&IID_IMediaEventEx
, riid
)) {
224 *ppvObj
= &This
->IMediaEventEx_iface
;
225 TRACE(" returning IMediaEvent(Ex) interface (%p)\n", *ppvObj
);
226 } else if (IsEqualGUID(&IID_IMediaFilter
, riid
) ||
227 IsEqualGUID(&IID_IPersist
, riid
)) {
228 *ppvObj
= &This
->IMediaFilter_iface
;
229 TRACE(" returning IMediaFilter interface (%p)\n", *ppvObj
);
230 } else if (IsEqualGUID(&IID_IMediaEventSink
, riid
)) {
231 *ppvObj
= &This
->IMediaEventSink_iface
;
232 TRACE(" returning IMediaEventSink interface (%p)\n", *ppvObj
);
233 } else if (IsEqualGUID(&IID_IGraphConfig
, riid
)) {
234 *ppvObj
= &This
->IGraphConfig_iface
;
235 TRACE(" returning IGraphConfig interface (%p)\n", *ppvObj
);
236 } else if (IsEqualGUID(&IID_IMediaPosition
, riid
)) {
237 *ppvObj
= &This
->IMediaPosition_iface
;
238 TRACE(" returning IMediaPosition interface (%p)\n", *ppvObj
);
239 } else if (IsEqualGUID(&IID_IObjectWithSite
, riid
)) {
240 *ppvObj
= &This
->IObjectWithSite_iface
;
241 TRACE(" returning IObjectWithSite interface (%p)\n", *ppvObj
);
242 } else if (IsEqualGUID(&IID_IFilterMapper
, riid
)) {
243 TRACE(" requesting IFilterMapper interface from aggregated filtermapper (%p)\n", *ppvObj
);
244 return IUnknown_QueryInterface(This
->punkFilterMapper2
, riid
, ppvObj
);
245 } else if (IsEqualGUID(&IID_IFilterMapper2
, riid
)) {
246 *ppvObj
= This
->pFilterMapper2
;
247 TRACE(" returning IFilterMapper2 interface from aggregated filtermapper (%p)\n", *ppvObj
);
248 } else if (IsEqualGUID(&IID_IFilterMapper3
, riid
)) {
249 *ppvObj
= This
->pFilterMapper2
;
250 TRACE(" returning IFilterMapper3 interface from aggregated filtermapper (%p)\n", *ppvObj
);
251 } else if (IsEqualGUID(&IID_IGraphVersion
, riid
)) {
252 *ppvObj
= &This
->IGraphConfig_iface
;
253 TRACE(" returning IGraphConfig interface (%p)\n", *ppvObj
);
256 FIXME("unknown interface %s\n", debugstr_guid(riid
));
257 return E_NOINTERFACE
;
260 IUnknown_AddRef((IUnknown
*)*ppvObj
);
264 static ULONG WINAPI
FilterGraphInner_AddRef(IUnknown
*iface
)
266 IFilterGraphImpl
*This
= impl_from_IUnknown(iface
);
267 ULONG ref
= InterlockedIncrement(&This
->ref
);
269 TRACE("(%p)->(): new ref = %d\n", This
, ref
);
274 static ULONG WINAPI
FilterGraphInner_Release(IUnknown
*iface
)
276 IFilterGraphImpl
*This
= impl_from_IUnknown(iface
);
277 ULONG ref
= InterlockedDecrement(&This
->ref
);
279 TRACE("(%p)->(): new ref = %d\n", This
, ref
);
284 This
->ref
= 1; /* guard against reentrancy (aggregation). */
286 IMediaControl_Stop(&This
->IMediaControl_iface
);
288 while (This
->nFilters
)
289 IFilterGraph2_RemoveFilter(&This
->IFilterGraph2_iface
, This
->ppFiltersInGraph
[0]);
292 IReferenceClock_Release(This
->refClock
);
294 for (i
= 0; i
< This
->nItfCacheEntries
; i
++)
296 if (This
->ItfCacheEntries
[i
].iface
)
297 IUnknown_Release(This
->ItfCacheEntries
[i
].iface
);
300 /* AddRef on controlling IUnknown, to compensate for Release of cached IFilterMapper2 */
301 IUnknown_AddRef(This
->outer_unk
);
302 IFilterMapper2_Release(This
->pFilterMapper2
);
303 IUnknown_Release(This
->punkFilterMapper2
);
305 if (This
->pSite
) IUnknown_Release(This
->pSite
);
307 CloseHandle(This
->hEventCompletion
);
308 EventsQueue_Destroy(&This
->evqueue
);
309 This
->cs
.DebugInfo
->Spare
[0] = 0;
310 DeleteCriticalSection(&This
->cs
);
311 CoTaskMemFree(This
->ppFiltersInGraph
);
312 CoTaskMemFree(This
->pFilterNames
);
318 static inline IFilterGraphImpl
*impl_from_IFilterGraph2(IFilterGraph2
*iface
)
320 return CONTAINING_RECORD(iface
, IFilterGraphImpl
, IFilterGraph2_iface
);
323 static HRESULT WINAPI
FilterGraph2_QueryInterface(IFilterGraph2
*iface
, REFIID riid
, void **ppvObj
)
325 IFilterGraphImpl
*This
= impl_from_IFilterGraph2(iface
);
327 TRACE("(%p/%p)->(%s (%p), %p)\n", This
, iface
, debugstr_guid(riid
), riid
, ppvObj
);
329 return IUnknown_QueryInterface(This
->outer_unk
, riid
, ppvObj
);
332 static ULONG WINAPI
FilterGraph2_AddRef(IFilterGraph2
*iface
)
334 IFilterGraphImpl
*This
= impl_from_IFilterGraph2(iface
);
336 TRACE("(%p/%p)->()\n", This
, iface
);
338 return IUnknown_AddRef(This
->outer_unk
);
341 static ULONG WINAPI
FilterGraph2_Release(IFilterGraph2
*iface
)
343 IFilterGraphImpl
*This
= impl_from_IFilterGraph2(iface
);
345 TRACE("(%p/%p)->()\n", This
, iface
);
347 return IUnknown_Release(This
->outer_unk
);
350 /*** IFilterGraph methods ***/
351 static HRESULT WINAPI
FilterGraph2_AddFilter(IFilterGraph2
*iface
, IBaseFilter
*pFilter
,
354 IFilterGraphImpl
*This
= impl_from_IFilterGraph2(iface
);
357 WCHAR
* wszFilterName
= NULL
;
358 BOOL duplicate_name
= FALSE
;
360 TRACE("(%p/%p)->(%p, %s (%p))\n", This
, iface
, pFilter
, debugstr_w(pName
), pName
);
365 wszFilterName
= CoTaskMemAlloc( (pName
? strlenW(pName
) + 6 : 5) * sizeof(WCHAR
) );
369 /* Check if name already exists */
370 for(i
= 0; i
< This
->nFilters
; i
++)
371 if (!strcmpW(This
->pFilterNames
[i
], pName
))
373 duplicate_name
= TRUE
;
378 /* If no name given or name already existing, generate one */
379 if (!pName
|| duplicate_name
)
381 static const WCHAR wszFmt1
[] = {'%','s',' ','%','0','4','d',0};
382 static const WCHAR wszFmt2
[] = {'%','0','4','d',0};
384 for (j
= 0; j
< 10000 ; j
++)
388 sprintfW(wszFilterName
, wszFmt1
, pName
, This
->nameIndex
);
390 sprintfW(wszFilterName
, wszFmt2
, This
->nameIndex
);
391 TRACE("Generated name %s\n", debugstr_w(wszFilterName
));
393 /* Check if the generated name already exists */
394 for(i
= 0; i
< This
->nFilters
; i
++)
395 if (!strcmpW(This
->pFilterNames
[i
], wszFilterName
))
398 /* Compute next index and exit if generated name is suitable */
399 if (This
->nameIndex
++ == 10000)
401 if (i
== This
->nFilters
)
404 /* Unable to find a suitable name */
407 CoTaskMemFree(wszFilterName
);
408 return VFW_E_DUPLICATE_NAME
;
412 memcpy(wszFilterName
, pName
, (strlenW(pName
) + 1) * sizeof(WCHAR
));
414 if (This
->nFilters
+ 1 > This
->filterCapacity
)
416 int newCapacity
= This
->filterCapacity
? 2 * This
->filterCapacity
: 1;
417 IBaseFilter
** ppNewFilters
= CoTaskMemAlloc(newCapacity
* sizeof(IBaseFilter
*));
418 LPWSTR
* pNewNames
= CoTaskMemAlloc(newCapacity
* sizeof(LPWSTR
));
419 memcpy(ppNewFilters
, This
->ppFiltersInGraph
, This
->nFilters
* sizeof(IBaseFilter
*));
420 memcpy(pNewNames
, This
->pFilterNames
, This
->nFilters
* sizeof(LPWSTR
));
421 if (This
->filterCapacity
)
423 CoTaskMemFree(This
->ppFiltersInGraph
);
424 CoTaskMemFree(This
->pFilterNames
);
426 This
->ppFiltersInGraph
= ppNewFilters
;
427 This
->pFilterNames
= pNewNames
;
428 This
->filterCapacity
= newCapacity
;
431 hr
= IBaseFilter_JoinFilterGraph(pFilter
, (IFilterGraph
*)&This
->IFilterGraph2_iface
, wszFilterName
);
435 IBaseFilter_AddRef(pFilter
);
436 This
->ppFiltersInGraph
[This
->nFilters
] = pFilter
;
437 This
->pFilterNames
[This
->nFilters
] = wszFilterName
;
440 IBaseFilter_SetSyncSource(pFilter
, This
->refClock
);
443 CoTaskMemFree(wszFilterName
);
445 if (SUCCEEDED(hr
) && duplicate_name
)
446 return VFW_S_DUPLICATE_NAME
;
451 static HRESULT WINAPI
FilterGraph2_RemoveFilter(IFilterGraph2
*iface
, IBaseFilter
*pFilter
)
453 IFilterGraphImpl
*This
= impl_from_IFilterGraph2(iface
);
457 TRACE("(%p/%p)->(%p)\n", This
, iface
, pFilter
);
459 /* FIXME: check graph is stopped */
461 for (i
= 0; i
< This
->nFilters
; i
++)
463 if (This
->ppFiltersInGraph
[i
] == pFilter
)
465 IEnumPins
*penumpins
= NULL
;
468 if (This
->defaultclock
&& This
->refClockProvider
== pFilter
)
470 IMediaFilter_SetSyncSource(&This
->IMediaFilter_iface
, NULL
);
471 This
->defaultclock
= TRUE
;
474 TRACE("Removing filter %s\n", debugstr_w(This
->pFilterNames
[i
]));
475 IBaseFilter_GetState(pFilter
, 0, &state
);
476 if (state
== State_Running
)
477 IBaseFilter_Pause(pFilter
);
478 if (state
!= State_Stopped
)
479 IBaseFilter_Stop(pFilter
);
481 hr
= IBaseFilter_EnumPins(pFilter
, &penumpins
);
484 while(IEnumPins_Next(penumpins
, 1, &ppin
, NULL
) == S_OK
)
488 IPin_ConnectedTo(ppin
, &victim
);
491 h
= IPin_Disconnect(victim
);
492 TRACE("Disconnect other side: %08x\n", h
);
493 if (h
== VFW_E_NOT_STOPPED
)
496 IPin_QueryPinInfo(victim
, &pinfo
);
498 IBaseFilter_GetState(pinfo
.pFilter
, 0, &state
);
499 if (state
== State_Running
)
500 IBaseFilter_Pause(pinfo
.pFilter
);
501 IBaseFilter_Stop(pinfo
.pFilter
);
502 IBaseFilter_Release(pinfo
.pFilter
);
503 h
= IPin_Disconnect(victim
);
504 TRACE("Disconnect retry: %08x\n", h
);
506 IPin_Release(victim
);
508 h
= IPin_Disconnect(ppin
);
509 TRACE("Disconnect 2: %08x\n", h
);
513 IEnumPins_Release(penumpins
);
516 hr
= IBaseFilter_JoinFilterGraph(pFilter
, NULL
, This
->pFilterNames
[i
]);
519 IBaseFilter_SetSyncSource(pFilter
, NULL
);
520 IBaseFilter_Release(pFilter
);
521 CoTaskMemFree(This
->pFilterNames
[i
]);
522 memmove(This
->ppFiltersInGraph
+i
, This
->ppFiltersInGraph
+i
+1, sizeof(IBaseFilter
*)*(This
->nFilters
- 1 - i
));
523 memmove(This
->pFilterNames
+i
, This
->pFilterNames
+i
+1, sizeof(LPWSTR
)*(This
->nFilters
- 1 - i
));
526 /* Invalidate interfaces in the cache */
527 for (i
= 0; i
< This
->nItfCacheEntries
; i
++)
528 if (pFilter
== This
->ItfCacheEntries
[i
].filter
)
530 IUnknown_Release(This
->ItfCacheEntries
[i
].iface
);
531 This
->ItfCacheEntries
[i
].iface
= NULL
;
532 This
->ItfCacheEntries
[i
].filter
= NULL
;
540 return hr
; /* FIXME: check this error code */
543 static HRESULT WINAPI
FilterGraph2_EnumFilters(IFilterGraph2
*iface
, IEnumFilters
**ppEnum
)
545 IFilterGraphImpl
*This
= impl_from_IFilterGraph2(iface
);
547 TRACE("(%p/%p)->(%p)\n", This
, iface
, ppEnum
);
549 return IEnumFiltersImpl_Construct(&This
->IGraphVersion_iface
, &This
->ppFiltersInGraph
, &This
->nFilters
, ppEnum
);
552 static HRESULT WINAPI
FilterGraph2_FindFilterByName(IFilterGraph2
*iface
, LPCWSTR pName
,
553 IBaseFilter
**ppFilter
)
555 IFilterGraphImpl
*This
= impl_from_IFilterGraph2(iface
);
558 TRACE("(%p/%p)->(%s (%p), %p)\n", This
, iface
, debugstr_w(pName
), pName
, ppFilter
);
563 for (i
= 0; i
< This
->nFilters
; i
++)
565 if (!strcmpW(pName
, This
->pFilterNames
[i
]))
567 *ppFilter
= This
->ppFiltersInGraph
[i
];
568 IBaseFilter_AddRef(*ppFilter
);
574 return VFW_E_NOT_FOUND
;
577 /* Don't allow a circular connection to form, return VFW_E_CIRCULAR_GRAPH if this would be the case.
578 * A circular connection will be formed if from the filter of the output pin, the input pin can be reached
580 static HRESULT
CheckCircularConnection(IFilterGraphImpl
*This
, IPin
*out
, IPin
*in
)
584 PIN_INFO info_out
, info_in
;
586 hr
= IPin_QueryPinInfo(out
, &info_out
);
589 if (info_out
.dir
!= PINDIR_OUTPUT
)
591 IBaseFilter_Release(info_out
.pFilter
);
592 return VFW_E_CANNOT_CONNECT
;
595 hr
= IPin_QueryPinInfo(in
, &info_in
);
597 IBaseFilter_Release(info_in
.pFilter
);
600 if (info_in
.dir
!= PINDIR_INPUT
)
602 hr
= VFW_E_CANNOT_CONNECT
;
606 if (info_out
.pFilter
== info_in
.pFilter
)
607 hr
= VFW_E_CIRCULAR_GRAPH
;
613 hr
= IBaseFilter_EnumPins(info_out
.pFilter
, &enumpins
);
617 IEnumPins_Reset(enumpins
);
618 while ((hr
= IEnumPins_Next(enumpins
, 1, &test
, NULL
)) == S_OK
)
620 PIN_DIRECTION dir
= PINDIR_OUTPUT
;
621 IPin_QueryDirection(test
, &dir
);
622 if (dir
== PINDIR_INPUT
)
625 IPin_ConnectedTo(test
, &victim
);
628 hr
= CheckCircularConnection(This
, victim
, in
);
629 IPin_Release(victim
);
639 IEnumPins_Release(enumpins
);
643 IBaseFilter_Release(info_out
.pFilter
);
645 ERR("Checking filtergraph returned %08x, something's not right!\n", hr
);
648 /* Debugging filtergraphs not enabled */
654 /* NOTE: despite the implication, it doesn't matter which
655 * way round you put in the input and output pins */
656 static HRESULT WINAPI
FilterGraph2_ConnectDirect(IFilterGraph2
*iface
, IPin
*ppinIn
, IPin
*ppinOut
,
657 const AM_MEDIA_TYPE
*pmt
)
659 IFilterGraphImpl
*This
= impl_from_IFilterGraph2(iface
);
663 TRACE("(%p/%p)->(%p, %p, %p)\n", This
, iface
, ppinIn
, ppinOut
, pmt
);
665 /* FIXME: check pins are in graph */
667 if (TRACE_ON(quartz
))
671 hr
= IPin_QueryPinInfo(ppinIn
, &PinInfo
);
675 TRACE("Filter owning first pin => %p\n", PinInfo
.pFilter
);
676 IBaseFilter_Release(PinInfo
.pFilter
);
678 hr
= IPin_QueryPinInfo(ppinOut
, &PinInfo
);
682 TRACE("Filter owning second pin => %p\n", PinInfo
.pFilter
);
683 IBaseFilter_Release(PinInfo
.pFilter
);
686 hr
= IPin_QueryDirection(ppinIn
, &dir
);
689 if (dir
== PINDIR_INPUT
)
691 hr
= CheckCircularConnection(This
, ppinOut
, ppinIn
);
693 hr
= IPin_Connect(ppinOut
, ppinIn
, pmt
);
697 hr
= CheckCircularConnection(This
, ppinIn
, ppinOut
);
699 hr
= IPin_Connect(ppinIn
, ppinOut
, pmt
);
706 static HRESULT WINAPI
FilterGraph2_Reconnect(IFilterGraph2
*iface
, IPin
*ppin
)
708 IFilterGraphImpl
*This
= impl_from_IFilterGraph2(iface
);
709 IPin
*pConnectedTo
= NULL
;
711 PIN_DIRECTION pindir
;
713 IPin_QueryDirection(ppin
, &pindir
);
714 hr
= IPin_ConnectedTo(ppin
, &pConnectedTo
);
716 TRACE("Querying connected to failed: %x\n", hr
);
719 IPin_Disconnect(ppin
);
720 IPin_Disconnect(pConnectedTo
);
721 if (pindir
== PINDIR_INPUT
)
722 hr
= IPin_Connect(pConnectedTo
, ppin
, NULL
);
724 hr
= IPin_Connect(ppin
, pConnectedTo
, NULL
);
725 IPin_Release(pConnectedTo
);
727 WARN("Reconnecting pins failed, pins are not connected now..\n");
728 TRACE("(%p->%p) -- %p %p -> %x\n", iface
, This
, ppin
, pConnectedTo
, hr
);
732 static HRESULT WINAPI
FilterGraph2_Disconnect(IFilterGraph2
*iface
, IPin
*ppin
)
734 IFilterGraphImpl
*This
= impl_from_IFilterGraph2(iface
);
736 TRACE("(%p/%p)->(%p)\n", This
, iface
, ppin
);
741 return IPin_Disconnect(ppin
);
744 static HRESULT WINAPI
FilterGraph2_SetDefaultSyncSource(IFilterGraph2
*iface
)
746 IFilterGraphImpl
*This
= impl_from_IFilterGraph2(iface
);
747 IReferenceClock
*pClock
= NULL
;
751 TRACE("(%p/%p)->() live sources not handled properly!\n", iface
, This
);
753 EnterCriticalSection(&This
->cs
);
755 for (i
= 0; i
< This
->nFilters
; ++i
)
758 IAMFilterMiscFlags
*flags
= NULL
;
759 IBaseFilter_QueryInterface(This
->ppFiltersInGraph
[i
], &IID_IAMFilterMiscFlags
, (void**)&flags
);
762 miscflags
= IAMFilterMiscFlags_GetMiscFlags(flags
);
763 IAMFilterMiscFlags_Release(flags
);
764 if (miscflags
== AM_FILTER_MISC_FLAGS_IS_RENDERER
)
765 IBaseFilter_QueryInterface(This
->ppFiltersInGraph
[i
], &IID_IReferenceClock
, (void**)&pClock
);
772 hr
= CoCreateInstance(&CLSID_SystemClock
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IReferenceClock
, (LPVOID
*)&pClock
);
773 This
->refClockProvider
= NULL
;
776 This
->refClockProvider
= This
->ppFiltersInGraph
[i
];
780 hr
= IMediaFilter_SetSyncSource(&This
->IMediaFilter_iface
, pClock
);
781 This
->defaultclock
= TRUE
;
782 IReferenceClock_Release(pClock
);
784 LeaveCriticalSection(&This
->cs
);
789 static HRESULT
GetFilterInfo(IMoniker
* pMoniker
, VARIANT
* pvar
)
791 static const WCHAR wszFriendlyName
[] = {'F','r','i','e','n','d','l','y','N','a','m','e',0};
792 IPropertyBag
* pPropBagCat
= NULL
;
797 hr
= IMoniker_BindToStorage(pMoniker
, NULL
, NULL
, &IID_IPropertyBag
, (LPVOID
*)&pPropBagCat
);
800 hr
= IPropertyBag_Read(pPropBagCat
, wszFriendlyName
, pvar
, NULL
);
803 TRACE("Moniker = %s\n", debugstr_w(V_BSTR(pvar
)));
806 IPropertyBag_Release(pPropBagCat
);
811 static HRESULT
GetInternalConnections(IBaseFilter
* pfilter
, IPin
* pinputpin
, IPin
*** pppins
, ULONG
* pnb
)
816 TRACE("(%p, %p, %p, %p)\n", pfilter
, pinputpin
, pppins
, pnb
);
817 hr
= IPin_QueryInternalConnections(pinputpin
, NULL
, &nb
);
820 } else if (hr
== S_FALSE
) {
821 *pppins
= CoTaskMemAlloc(sizeof(IPin
*)*nb
);
822 hr
= IPin_QueryInternalConnections(pinputpin
, *pppins
, &nb
);
824 WARN("Error (%x)\n", hr
);
826 } else if (hr
== E_NOTIMPL
) {
827 /* Input connected to all outputs */
828 IEnumPins
* penumpins
;
831 TRACE("E_NOTIMPL\n");
832 hr
= IBaseFilter_EnumPins(pfilter
, &penumpins
);
834 WARN("filter Enumpins failed (%x)\n", hr
);
838 /* Count output pins */
839 while(IEnumPins_Next(penumpins
, 1, &ppin
, &nb
) == S_OK
) {
840 PIN_DIRECTION pindir
;
841 IPin_QueryDirection(ppin
, &pindir
);
842 if (pindir
== PINDIR_OUTPUT
)
846 *pppins
= CoTaskMemAlloc(sizeof(IPin
*)*i
);
847 /* Retrieve output pins */
848 IEnumPins_Reset(penumpins
);
850 while(IEnumPins_Next(penumpins
, 1, &ppin
, &nb
) == S_OK
) {
851 PIN_DIRECTION pindir
;
852 IPin_QueryDirection(ppin
, &pindir
);
853 if (pindir
== PINDIR_OUTPUT
)
854 (*pppins
)[i
++] = ppin
;
858 IEnumPins_Release(penumpins
);
861 WARN("Next failed (%x)\n", hr
);
864 } else if (FAILED(hr
)) {
865 WARN("Cannot get internal connection (%x)\n", hr
);
873 /*** IGraphBuilder methods ***/
874 static HRESULT WINAPI
FilterGraph2_Connect(IFilterGraph2
*iface
, IPin
*ppinOut
, IPin
*ppinIn
)
876 IFilterGraphImpl
*This
= impl_from_IFilterGraph2(iface
);
878 AM_MEDIA_TYPE
* mt
= NULL
;
879 IEnumMediaTypes
* penummt
= NULL
;
881 IEnumPins
* penumpins
;
882 IEnumMoniker
* pEnumMoniker
;
892 TRACE("(%p/%p)->(%p, %p)\n", This
, iface
, ppinOut
, ppinIn
);
894 if(!ppinOut
|| !ppinIn
)
897 if (TRACE_ON(quartz
))
899 hr
= IPin_QueryPinInfo(ppinIn
, &PinInfo
);
903 TRACE("Filter owning first pin => %p\n", PinInfo
.pFilter
);
904 IBaseFilter_Release(PinInfo
.pFilter
);
906 hr
= IPin_QueryPinInfo(ppinOut
, &PinInfo
);
910 TRACE("Filter owning second pin => %p\n", PinInfo
.pFilter
);
911 IBaseFilter_Release(PinInfo
.pFilter
);
914 EnterCriticalSection(&This
->cs
);
915 ++This
->recursioncount
;
916 if (This
->recursioncount
>= 5)
918 WARN("Recursion count has reached %d\n", This
->recursioncount
);
919 hr
= VFW_E_CANNOT_CONNECT
;
923 hr
= IPin_QueryDirection(ppinOut
, &dir
);
927 if (dir
== PINDIR_INPUT
)
936 hr
= CheckCircularConnection(This
, ppinOut
, ppinIn
);
940 /* Try direct connection first */
941 hr
= IPin_Connect(ppinOut
, ppinIn
, NULL
);
945 TRACE("Direct connection failed, trying to render using extra filters\n");
947 hr
= IPin_QueryPinInfo(ppinIn
, &PinInfo
);
951 hr
= IBaseFilter_GetClassID(PinInfo
.pFilter
, &FilterCLSID
);
952 IBaseFilter_Release(PinInfo
.pFilter
);
956 /* Find the appropriate transform filter than can transform the minor media type of output pin of the upstream
957 * filter to the minor mediatype of input pin of the renderer */
958 hr
= IPin_EnumMediaTypes(ppinOut
, &penummt
);
961 WARN("EnumMediaTypes (%x)\n", hr
);
965 hr
= IEnumMediaTypes_Next(penummt
, 1, &mt
, &nbmt
);
967 WARN("IEnumMediaTypes_Next (%x)\n", hr
);
973 WARN("No media type found!\n");
974 hr
= VFW_E_INVALIDMEDIATYPE
;
977 TRACE("MajorType %s\n", debugstr_guid(&mt
->majortype
));
978 TRACE("SubType %s\n", debugstr_guid(&mt
->subtype
));
980 /* Try to find a suitable filter that can connect to the pin to render */
981 tab
[0] = mt
->majortype
;
982 tab
[1] = mt
->subtype
;
983 hr
= IFilterMapper2_EnumMatchingFilters(This
->pFilterMapper2
, &pEnumMoniker
, 0, FALSE
, MERIT_UNLIKELY
, TRUE
, 1, tab
, NULL
, NULL
, FALSE
, FALSE
, 0, NULL
, NULL
, NULL
);
985 WARN("Unable to enum filters (%x)\n", hr
);
989 hr
= VFW_E_CANNOT_RENDER
;
990 while(IEnumMoniker_Next(pEnumMoniker
, 1, &pMoniker
, &nb
) == S_OK
)
995 IPin
* ppinfilter
= NULL
;
996 IBaseFilter
* pfilter
= NULL
;
997 IAMGraphBuilderCallback
*callback
= NULL
;
999 hr
= GetFilterInfo(pMoniker
, &var
);
1001 WARN("Unable to retrieve filter info (%x)\n", hr
);
1005 hr
= IMoniker_BindToObject(pMoniker
, NULL
, NULL
, &IID_IBaseFilter
, (LPVOID
*)&pfilter
);
1006 IMoniker_Release(pMoniker
);
1008 WARN("Unable to create filter (%x), trying next one\n", hr
);
1012 hr
= IBaseFilter_GetClassID(pfilter
, &clsid
);
1015 IBaseFilter_Release(pfilter
);
1019 if (IsEqualGUID(&clsid
, &FilterCLSID
)) {
1020 /* Skip filter (same as the one the output pin belongs to) */
1021 IBaseFilter_Release(pfilter
);
1027 IUnknown_QueryInterface(This
->pSite
, &IID_IAMGraphBuilderCallback
, (LPVOID
*)&callback
);
1031 rc
= IAMGraphBuilderCallback_SelectedFilter(callback
, pMoniker
);
1034 TRACE("Filter rejected by IAMGraphBuilderCallback_SelectedFilter\n");
1035 IAMGraphBuilderCallback_Release(callback
);
1044 rc
= IAMGraphBuilderCallback_CreatedFilter(callback
, pfilter
);
1045 IAMGraphBuilderCallback_Release(callback
);
1048 IBaseFilter_Release(pfilter
);
1050 TRACE("Filter rejected by IAMGraphBuilderCallback_CreatedFilter\n");
1055 hr
= IFilterGraph2_AddFilter(iface
, pfilter
, V_BSTR(&var
));
1057 WARN("Unable to add filter (%x)\n", hr
);
1058 IBaseFilter_Release(pfilter
);
1065 hr
= IBaseFilter_EnumPins(pfilter
, &penumpins
);
1067 WARN("Enumpins (%x)\n", hr
);
1071 hr
= IEnumPins_Next(penumpins
, 1, &ppinfilter
, &pin
);
1072 IEnumPins_Release(penumpins
);
1075 WARN("Obtaining next pin: (%x)\n", hr
);
1079 WARN("Cannot use this filter: no pins\n");
1083 hr
= IPin_Connect(ppinOut
, ppinfilter
, NULL
);
1085 TRACE("Cannot connect to filter (%x), trying next one\n", hr
);
1088 TRACE("Successfully connected to filter, follow chain...\n");
1090 /* Render all output pins of the filter by calling IFilterGraph2_Connect on each of them */
1091 hr
= GetInternalConnections(pfilter
, ppinfilter
, &ppins
, &nb
);
1093 if (SUCCEEDED(hr
)) {
1095 IPin_Disconnect(ppinfilter
);
1096 IPin_Disconnect(ppinOut
);
1099 TRACE("pins to consider: %d\n", nb
);
1100 for(i
= 0; i
< nb
; i
++)
1102 LPWSTR pinname
= NULL
;
1104 TRACE("Processing pin %u\n", i
);
1106 hr
= IPin_QueryId(ppins
[i
], &pinname
);
1109 if (pinname
[0] == '~')
1111 TRACE("Pinname=%s, skipping\n", debugstr_w(pinname
));
1115 hr
= IFilterGraph2_Connect(iface
, ppins
[i
], ppinIn
);
1116 CoTaskMemFree(pinname
);
1120 TRACE("Cannot connect pin %p (%x)\n", ppinfilter
, hr
);
1122 IPin_Release(ppins
[i
]);
1123 if (SUCCEEDED(hr
)) break;
1125 while (++i
< nb
) IPin_Release(ppins
[i
]);
1126 CoTaskMemFree(ppins
);
1127 IPin_Release(ppinfilter
);
1128 IBaseFilter_Release(pfilter
);
1131 IPin_Disconnect(ppinfilter
);
1132 IPin_Disconnect(ppinOut
);
1133 IFilterGraph2_RemoveFilter(iface
, pfilter
);
1141 if (ppinfilter
) IPin_Release(ppinfilter
);
1143 IFilterGraph2_RemoveFilter(iface
, pfilter
);
1144 IBaseFilter_Release(pfilter
);
1146 while (++i
< nb
) IPin_Release(ppins
[i
]);
1147 CoTaskMemFree(ppins
);
1152 IEnumMediaTypes_Release(penummt
);
1154 DeleteMediaType(mt
);
1155 --This
->recursioncount
;
1156 LeaveCriticalSection(&This
->cs
);
1157 TRACE("--> %08x\n", hr
);
1158 return SUCCEEDED(hr
) ? S_OK
: hr
;
1161 static HRESULT
FilterGraph2_RenderRecurse(IFilterGraphImpl
*This
, IPin
*ppinOut
)
1163 /* This pin has been connected now, try to call render on all pins that aren't connected */
1166 IEnumPins
*enumpins
= NULL
;
1167 BOOL renderany
= FALSE
;
1168 BOOL renderall
= TRUE
;
1170 IPin_QueryPinInfo(ppinOut
, &info
);
1172 IBaseFilter_EnumPins(info
.pFilter
, &enumpins
);
1173 /* Don't need to hold a reference, IEnumPins does */
1174 IBaseFilter_Release(info
.pFilter
);
1176 IEnumPins_Reset(enumpins
);
1177 while (IEnumPins_Next(enumpins
, 1, &to
, NULL
) == S_OK
)
1179 PIN_DIRECTION dir
= PINDIR_INPUT
;
1181 IPin_QueryDirection(to
, &dir
);
1183 if (dir
== PINDIR_OUTPUT
)
1187 IPin_ConnectedTo(to
, &out
);
1191 hr
= IFilterGraph2_Render(&This
->IFilterGraph2_iface
, to
);
1204 IEnumPins_Release(enumpins
);
1210 return VFW_S_PARTIAL_RENDER
;
1212 return VFW_E_CANNOT_RENDER
;
1215 /* Ogg hates me if I create a direct rendering method
1217 * It can only connect to a pin properly once, so use a recursive method that does
1219 * +----+ --- (PIN 1) (Render is called on this pin)
1221 * +----+ --- (PIN 2)
1223 * Enumerate possible renderers that EXACTLY match the requested type
1225 * If none is available, try to add intermediate filters that can connect to the input pin
1226 * then call Render on that intermediate pin's output pins
1227 * if it succeeds: Render returns success, if it doesn't, the intermediate filter is removed,
1228 * and another filter that can connect to the input pin is tried
1229 * if we run out of filters that can, give up and return VFW_E_CANNOT_RENDER
1230 * It's recursive, but fun!
1233 static HRESULT WINAPI
FilterGraph2_Render(IFilterGraph2
*iface
, IPin
*ppinOut
)
1235 IFilterGraphImpl
*This
= impl_from_IFilterGraph2(iface
);
1236 IEnumMediaTypes
* penummt
;
1241 IEnumMoniker
* pEnumMoniker
;
1247 TRACE("(%p/%p)->(%p)\n", This
, iface
, ppinOut
);
1249 if (TRACE_ON(quartz
))
1253 hr
= IPin_QueryPinInfo(ppinOut
, &PinInfo
);
1257 TRACE("Filter owning pin => %p\n", PinInfo
.pFilter
);
1258 IBaseFilter_Release(PinInfo
.pFilter
);
1261 /* Try to find out if there is a renderer for the specified subtype already, and use that
1263 EnterCriticalSection(&This
->cs
);
1264 for (x
= 0; x
< This
->nFilters
; ++x
)
1266 IEnumPins
*enumpins
= NULL
;
1269 hr
= IBaseFilter_EnumPins(This
->ppFiltersInGraph
[x
], &enumpins
);
1271 if (FAILED(hr
) || !enumpins
)
1274 IEnumPins_Reset(enumpins
);
1275 while (IEnumPins_Next(enumpins
, 1, &pin
, NULL
) == S_OK
)
1278 PIN_DIRECTION dir
= PINDIR_OUTPUT
;
1280 IPin_QueryDirection(pin
, &dir
);
1281 if (dir
!= PINDIR_INPUT
)
1286 IPin_ConnectedTo(pin
, &to
);
1290 hr
= FilterGraph2_ConnectDirect(iface
, ppinOut
, pin
, NULL
);
1293 TRACE("Connected successfully %p/%p, %08x look if we should render more!\n", ppinOut
, pin
, hr
);
1296 hr
= FilterGraph2_RenderRecurse(This
, pin
);
1299 IPin_Disconnect(ppinOut
);
1300 IPin_Disconnect(pin
);
1303 IEnumPins_Release(enumpins
);
1304 LeaveCriticalSection(&This
->cs
);
1307 WARN("Could not connect!\n");
1314 IEnumPins_Release(enumpins
);
1317 LeaveCriticalSection(&This
->cs
);
1319 hr
= IPin_EnumMediaTypes(ppinOut
, &penummt
);
1321 WARN("EnumMediaTypes (%x)\n", hr
);
1325 IEnumMediaTypes_Reset(penummt
);
1327 /* Looks like no existing renderer of the kind exists
1328 * Try adding new ones
1330 tab
[0] = tab
[1] = GUID_NULL
;
1331 while (SUCCEEDED(hr
))
1333 hr
= IEnumMediaTypes_Next(penummt
, 1, &mt
, &nbmt
);
1335 WARN("IEnumMediaTypes_Next (%x)\n", hr
);
1340 hr
= VFW_E_CANNOT_RENDER
;
1345 TRACE("MajorType %s\n", debugstr_guid(&mt
->majortype
));
1346 TRACE("SubType %s\n", debugstr_guid(&mt
->subtype
));
1348 /* Only enumerate once, this doesn't account for all previous ones, but this should be enough nonetheless */
1349 if (IsEqualIID(&tab
[0], &mt
->majortype
) && IsEqualIID(&tab
[1], &mt
->subtype
))
1351 DeleteMediaType(mt
);
1355 /* Try to find a suitable renderer with the same media type */
1356 tab
[0] = mt
->majortype
;
1357 tab
[1] = mt
->subtype
;
1358 hr
= IFilterMapper2_EnumMatchingFilters(This
->pFilterMapper2
, &pEnumMoniker
, 0, FALSE
, MERIT_UNLIKELY
, TRUE
, 1, tab
, NULL
, NULL
, FALSE
, FALSE
, 0, NULL
, NULL
, NULL
);
1361 WARN("Unable to enum filters (%x)\n", hr
);
1367 while (IEnumMoniker_Next(pEnumMoniker
, 1, &pMoniker
, &nb
) == S_OK
)
1371 IBaseFilter
* pfilter
= NULL
;
1372 IEnumPins
* penumpins
= NULL
;
1375 hr
= GetFilterInfo(pMoniker
, &var
);
1377 WARN("Unable to retrieve filter info (%x)\n", hr
);
1381 hr
= IMoniker_BindToObject(pMoniker
, NULL
, NULL
, &IID_IBaseFilter
, (LPVOID
*)&pfilter
);
1382 IMoniker_Release(pMoniker
);
1385 WARN("Unable to create filter (%x), trying next one\n", hr
);
1389 hr
= IFilterGraph2_AddFilter(iface
, pfilter
, V_BSTR(&var
));
1391 WARN("Unable to add filter (%x)\n", hr
);
1392 IBaseFilter_Release(pfilter
);
1397 hr
= IBaseFilter_EnumPins(pfilter
, &penumpins
);
1399 WARN("Splitter Enumpins (%x)\n", hr
);
1403 while ((hr
= IEnumPins_Next(penumpins
, 1, &ppinfilter
, &pin
)) == S_OK
)
1413 hr
= IPin_QueryDirection(ppinfilter
, &dir
);
1415 IPin_Release(ppinfilter
);
1416 WARN("QueryDirection failed (%x)\n", hr
);
1419 if (dir
!= PINDIR_INPUT
) {
1420 IPin_Release(ppinfilter
);
1421 continue; /* Wrong direction */
1424 /* Connect the pin to the "Renderer" */
1425 hr
= IPin_Connect(ppinOut
, ppinfilter
, NULL
);
1426 IPin_Release(ppinfilter
);
1429 WARN("Unable to connect %s to renderer (%x)\n", debugstr_w(V_BSTR(&var
)), hr
);
1432 TRACE("Connected, recursing %s\n", debugstr_w(V_BSTR(&var
)));
1436 hr
= FilterGraph2_RenderRecurse(This
, ppinfilter
);
1438 WARN("Unable to connect recursively (%x)\n", hr
);
1441 IBaseFilter_Release(pfilter
);
1444 if (SUCCEEDED(hr
)) {
1445 IEnumPins_Release(penumpins
);
1446 break; /* out of IEnumMoniker_Next loop */
1449 /* IEnumPins_Next failed, all other failure case caught by goto error */
1450 WARN("IEnumPins_Next (%x)\n", hr
);
1456 IEnumPins_Release(penumpins
);
1458 IFilterGraph2_RemoveFilter(iface
, pfilter
);
1459 IBaseFilter_Release(pfilter
);
1461 if (SUCCEEDED(hr
)) DebugBreak();
1464 IEnumMoniker_Release(pEnumMoniker
);
1466 DeleteMediaType(mt
);
1472 IEnumMediaTypes_Release(penummt
);
1476 static HRESULT WINAPI
FilterGraph2_RenderFile(IFilterGraph2
*iface
, LPCWSTR lpcwstrFile
,
1477 LPCWSTR lpcwstrPlayList
)
1479 IFilterGraphImpl
*This
= impl_from_IFilterGraph2(iface
);
1480 static const WCHAR string
[] = {'R','e','a','d','e','r',0};
1481 IBaseFilter
* preader
= NULL
;
1482 IPin
* ppinreader
= NULL
;
1483 IEnumPins
* penumpins
= NULL
;
1485 BOOL partial
= FALSE
;
1488 TRACE("(%p/%p)->(%s, %s)\n", This
, iface
, debugstr_w(lpcwstrFile
), debugstr_w(lpcwstrPlayList
));
1490 if (lpcwstrPlayList
!= NULL
)
1491 return E_INVALIDARG
;
1493 hr
= IFilterGraph2_AddSourceFilter(iface
, lpcwstrFile
, string
, &preader
);
1498 hr
= IBaseFilter_EnumPins(preader
, &penumpins
);
1501 while (IEnumPins_Next(penumpins
, 1, &ppinreader
, NULL
) == S_OK
)
1505 IPin_QueryDirection(ppinreader
, &dir
);
1506 if (dir
== PINDIR_OUTPUT
)
1510 hr
= IFilterGraph2_Render(iface
, ppinreader
);
1511 TRACE("Render %08x\n", hr
);
1513 for (i
= 0; i
< This
->nFilters
; ++i
)
1514 TRACE("Filters in chain: %s\n", debugstr_w(This
->pFilterNames
[i
]));
1521 IPin_Release(ppinreader
);
1523 IEnumPins_Release(penumpins
);
1526 hr
= VFW_E_CANNOT_RENDER
;
1528 hr
= VFW_S_PARTIAL_RENDER
;
1532 IBaseFilter_Release(preader
);
1534 TRACE("--> %08x\n", hr
);
1538 static HRESULT
CreateFilterInstanceAndLoadFile(GUID
* clsid
, LPCOLESTR pszFileName
, IBaseFilter
**filter
)
1540 IFileSourceFilter
*source
= NULL
;
1541 HRESULT hr
= CoCreateInstance(clsid
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IBaseFilter
, (LPVOID
*)filter
);
1542 TRACE("CLSID: %s\n", debugstr_guid(clsid
));
1546 hr
= IBaseFilter_QueryInterface(*filter
, &IID_IFileSourceFilter
, (LPVOID
*)&source
);
1549 IBaseFilter_Release(*filter
);
1553 /* Load the file in the file source filter */
1554 hr
= IFileSourceFilter_Load(source
, pszFileName
, NULL
);
1555 IFileSourceFilter_Release(source
);
1557 WARN("Load (%x)\n", hr
);
1558 IBaseFilter_Release(*filter
);
1565 /* Some filters implement their own asynchronous reader (Theoretically they all should, try to load it first */
1566 static HRESULT
GetFileSourceFilter(LPCOLESTR pszFileName
, IBaseFilter
**filter
)
1570 IAsyncReader
* pReader
= NULL
;
1571 IFileSourceFilter
* pSource
= NULL
;
1572 IPin
* pOutputPin
= NULL
;
1573 static const WCHAR wszOutputPinName
[] = { 'O','u','t','p','u','t',0 };
1575 /* Try to find a match without reading the file first */
1576 hr
= GetClassMediaFile(NULL
, pszFileName
, NULL
, NULL
, &clsid
);
1579 return CreateFilterInstanceAndLoadFile(&clsid
, pszFileName
, filter
);
1581 /* Now create a AyncReader instance, to check for signature bytes in the file */
1582 hr
= CoCreateInstance(&CLSID_AsyncReader
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IBaseFilter
, (LPVOID
*)filter
);
1586 hr
= IBaseFilter_QueryInterface(*filter
, &IID_IFileSourceFilter
, (LPVOID
*)&pSource
);
1589 IBaseFilter_Release(*filter
);
1593 hr
= IFileSourceFilter_Load(pSource
, pszFileName
, NULL
);
1594 IFileSourceFilter_Release(pSource
);
1597 IBaseFilter_Release(*filter
);
1601 hr
= IBaseFilter_FindPin(*filter
, wszOutputPinName
, &pOutputPin
);
1604 IBaseFilter_Release(*filter
);
1608 hr
= IPin_QueryInterface(pOutputPin
, &IID_IAsyncReader
, (LPVOID
*)&pReader
);
1609 IPin_Release(pOutputPin
);
1612 IBaseFilter_Release(*filter
);
1616 /* Try again find a match */
1617 hr
= GetClassMediaFile(pReader
, pszFileName
, NULL
, NULL
, &clsid
);
1618 IAsyncReader_Release(pReader
);
1622 /* Release the AsyncReader filter and create the matching one */
1623 IBaseFilter_Release(*filter
);
1624 return CreateFilterInstanceAndLoadFile(&clsid
, pszFileName
, filter
);
1627 /* Return the AsyncReader filter */
1631 static HRESULT WINAPI
FilterGraph2_AddSourceFilter(IFilterGraph2
*iface
, LPCWSTR lpcwstrFileName
,
1632 LPCWSTR lpcwstrFilterName
, IBaseFilter
**ppFilter
)
1634 IFilterGraphImpl
*This
= impl_from_IFilterGraph2(iface
);
1636 IBaseFilter
* preader
;
1637 IFileSourceFilter
* pfile
= NULL
;
1641 TRACE("(%p/%p)->(%s, %s, %p)\n", This
, iface
, debugstr_w(lpcwstrFileName
), debugstr_w(lpcwstrFilterName
), ppFilter
);
1643 /* Try from file name first, then fall back to default asynchronous reader */
1644 hr
= GetFileSourceFilter(lpcwstrFileName
, &preader
);
1646 WARN("Unable to create file source filter (%x)\n", hr
);
1650 hr
= IFilterGraph2_AddFilter(iface
, preader
, lpcwstrFilterName
);
1652 WARN("Unable add filter (%x)\n", hr
);
1653 IBaseFilter_Release(preader
);
1657 hr
= IBaseFilter_QueryInterface(preader
, &IID_IFileSourceFilter
, (LPVOID
*)&pfile
);
1659 WARN("Unable to get IFileSourceInterface (%x)\n", hr
);
1663 /* The file has been already loaded */
1664 hr
= IFileSourceFilter_GetCurFile(pfile
, &filename
, &mt
);
1666 WARN("GetCurFile (%x)\n", hr
);
1670 TRACE("File %s\n", debugstr_w(filename
));
1671 TRACE("MajorType %s\n", debugstr_guid(&mt
.majortype
));
1672 TRACE("SubType %s\n", debugstr_guid(&mt
.subtype
));
1675 *ppFilter
= preader
;
1676 IFileSourceFilter_Release(pfile
);
1682 IFileSourceFilter_Release(pfile
);
1683 IFilterGraph2_RemoveFilter(iface
, preader
);
1684 IBaseFilter_Release(preader
);
1689 static HRESULT WINAPI
FilterGraph2_SetLogFile(IFilterGraph2
*iface
, DWORD_PTR hFile
)
1691 IFilterGraphImpl
*This
= impl_from_IFilterGraph2(iface
);
1693 TRACE("(%p/%p)->(%08x): stub !!!\n", This
, iface
, (DWORD
) hFile
);
1698 static HRESULT WINAPI
FilterGraph2_Abort(IFilterGraph2
*iface
)
1700 IFilterGraphImpl
*This
= impl_from_IFilterGraph2(iface
);
1702 TRACE("(%p/%p)->(): stub !!!\n", This
, iface
);
1707 static HRESULT WINAPI
FilterGraph2_ShouldOperationContinue(IFilterGraph2
*iface
)
1709 IFilterGraphImpl
*This
= impl_from_IFilterGraph2(iface
);
1711 TRACE("(%p/%p)->(): stub !!!\n", This
, iface
);
1716 /*** IFilterGraph2 methods ***/
1717 static HRESULT WINAPI
FilterGraph2_AddSourceFilterForMoniker(IFilterGraph2
*iface
,
1718 IMoniker
*pMoniker
, IBindCtx
*pCtx
, LPCWSTR lpcwstrFilterName
, IBaseFilter
**ppFilter
)
1720 IFilterGraphImpl
*This
= impl_from_IFilterGraph2(iface
);
1722 IBaseFilter
* pfilter
;
1724 TRACE("(%p/%p)->(%p %p %s %p)\n", This
, iface
, pMoniker
, pCtx
, debugstr_w(lpcwstrFilterName
), ppFilter
);
1726 hr
= IMoniker_BindToObject(pMoniker
, pCtx
, NULL
, &IID_IBaseFilter
, (void**)&pfilter
);
1728 WARN("Unable to bind moniker to filter object (%x)\n", hr
);
1732 hr
= IFilterGraph2_AddFilter(iface
, pfilter
, lpcwstrFilterName
);
1734 WARN("Unable to add filter (%x)\n", hr
);
1735 IBaseFilter_Release(pfilter
);
1740 *ppFilter
= pfilter
;
1741 else IBaseFilter_Release(pfilter
);
1746 static HRESULT WINAPI
FilterGraph2_ReconnectEx(IFilterGraph2
*iface
, IPin
*ppin
,
1747 const AM_MEDIA_TYPE
*pmt
)
1749 IFilterGraphImpl
*This
= impl_from_IFilterGraph2(iface
);
1751 TRACE("(%p/%p)->(%p %p): stub !!!\n", This
, iface
, ppin
, pmt
);
1756 static HRESULT WINAPI
FilterGraph2_RenderEx(IFilterGraph2
*iface
, IPin
*pPinOut
, DWORD dwFlags
,
1759 IFilterGraphImpl
*This
= impl_from_IFilterGraph2(iface
);
1761 TRACE("(%p/%p)->(%p %08x %p): stub !!!\n", This
, iface
, pPinOut
, dwFlags
, pvContext
);
1767 static const IFilterGraph2Vtbl IFilterGraph2_VTable
=
1769 FilterGraph2_QueryInterface
,
1770 FilterGraph2_AddRef
,
1771 FilterGraph2_Release
,
1772 FilterGraph2_AddFilter
,
1773 FilterGraph2_RemoveFilter
,
1774 FilterGraph2_EnumFilters
,
1775 FilterGraph2_FindFilterByName
,
1776 FilterGraph2_ConnectDirect
,
1777 FilterGraph2_Reconnect
,
1778 FilterGraph2_Disconnect
,
1779 FilterGraph2_SetDefaultSyncSource
,
1780 FilterGraph2_Connect
,
1781 FilterGraph2_Render
,
1782 FilterGraph2_RenderFile
,
1783 FilterGraph2_AddSourceFilter
,
1784 FilterGraph2_SetLogFile
,
1786 FilterGraph2_ShouldOperationContinue
,
1787 FilterGraph2_AddSourceFilterForMoniker
,
1788 FilterGraph2_ReconnectEx
,
1789 FilterGraph2_RenderEx
1792 static inline IFilterGraphImpl
*impl_from_IMediaControl(IMediaControl
*iface
)
1794 return CONTAINING_RECORD(iface
, IFilterGraphImpl
, IMediaControl_iface
);
1797 static HRESULT WINAPI
MediaControl_QueryInterface(IMediaControl
*iface
, REFIID riid
, void **ppvObj
)
1799 IFilterGraphImpl
*This
= impl_from_IMediaControl(iface
);
1801 TRACE("(%p/%p)->(%s (%p), %p)\n", This
, iface
, debugstr_guid(riid
), riid
, ppvObj
);
1803 return IUnknown_QueryInterface(This
->outer_unk
, riid
, ppvObj
);
1806 static ULONG WINAPI
MediaControl_AddRef(IMediaControl
*iface
)
1808 IFilterGraphImpl
*This
= impl_from_IMediaControl(iface
);
1810 TRACE("(%p/%p)->()\n", This
, iface
);
1812 return IUnknown_AddRef(This
->outer_unk
);
1815 static ULONG WINAPI
MediaControl_Release(IMediaControl
*iface
)
1817 IFilterGraphImpl
*This
= impl_from_IMediaControl(iface
);
1819 TRACE("(%p/%p)->()\n", This
, iface
);
1821 return IUnknown_Release(This
->outer_unk
);
1825 /*** IDispatch methods ***/
1826 static HRESULT WINAPI
MediaControl_GetTypeInfoCount(IMediaControl
*iface
, UINT
*pctinfo
)
1828 IFilterGraphImpl
*This
= impl_from_IMediaControl(iface
);
1830 TRACE("(%p/%p)->(%p): stub !!!\n", This
, iface
, pctinfo
);
1835 static HRESULT WINAPI
MediaControl_GetTypeInfo(IMediaControl
*iface
, UINT iTInfo
, LCID lcid
,
1836 ITypeInfo
**ppTInfo
)
1838 IFilterGraphImpl
*This
= impl_from_IMediaControl(iface
);
1840 TRACE("(%p/%p)->(%d, %d, %p): stub !!!\n", This
, iface
, iTInfo
, lcid
, ppTInfo
);
1845 static HRESULT WINAPI
MediaControl_GetIDsOfNames(IMediaControl
*iface
, REFIID riid
,
1846 LPOLESTR
*rgszNames
, UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
1848 IFilterGraphImpl
*This
= impl_from_IMediaControl(iface
);
1850 TRACE("(%p/%p)->(%s (%p), %p, %d, %d, %p): stub !!!\n", This
, iface
, debugstr_guid(riid
), riid
, rgszNames
, cNames
, lcid
, rgDispId
);
1855 static HRESULT WINAPI
MediaControl_Invoke(IMediaControl
*iface
, DISPID dispIdMember
, REFIID riid
,
1856 LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
, VARIANT
*pVarResult
, EXCEPINFO
*pExepInfo
,
1859 IFilterGraphImpl
*This
= impl_from_IMediaControl(iface
);
1861 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
);
1866 typedef HRESULT(WINAPI
*fnFoundFilter
)(IBaseFilter
*, DWORD_PTR data
);
1868 static HRESULT
ExploreGraph(IFilterGraphImpl
* pGraph
, IPin
* pOutputPin
, fnFoundFilter FoundFilter
, DWORD_PTR data
)
1877 TRACE("%p %p\n", pGraph
, pOutputPin
);
1878 PinInfo
.pFilter
= NULL
;
1880 hr
= IPin_ConnectedTo(pOutputPin
, &pInputPin
);
1884 hr
= IPin_QueryPinInfo(pInputPin
, &PinInfo
);
1886 hr
= GetInternalConnections(PinInfo
.pFilter
, pInputPin
, &ppPins
, &nb
);
1887 IPin_Release(pInputPin
);
1894 TRACE("Reached a renderer\n");
1895 /* Count renderers for end of stream notification */
1896 pGraph
->nRenderers
++;
1900 for(i
= 0; i
< nb
; i
++)
1902 /* Explore the graph downstream from this pin
1903 * FIXME: We should prevent exploring from a pin more than once. This can happens when
1904 * several input pins are connected to the same output (a MUX for instance). */
1905 ExploreGraph(pGraph
, ppPins
[i
], FoundFilter
, data
);
1906 IPin_Release(ppPins
[i
]);
1909 CoTaskMemFree(ppPins
);
1911 TRACE("Doing stuff with filter %p\n", PinInfo
.pFilter
);
1913 FoundFilter(PinInfo
.pFilter
, data
);
1916 if (PinInfo
.pFilter
) IBaseFilter_Release(PinInfo
.pFilter
);
1920 static HRESULT WINAPI
SendRun(IBaseFilter
*pFilter
, DWORD_PTR data
)
1922 REFERENCE_TIME time
= *(REFERENCE_TIME
*)data
;
1923 return IBaseFilter_Run(pFilter
, time
);
1926 static HRESULT WINAPI
SendPause(IBaseFilter
*pFilter
, DWORD_PTR data
)
1928 return IBaseFilter_Pause(pFilter
);
1931 static HRESULT WINAPI
SendStop(IBaseFilter
*pFilter
, DWORD_PTR data
)
1933 return IBaseFilter_Stop(pFilter
);
1936 static HRESULT WINAPI
SendGetState(IBaseFilter
*pFilter
, DWORD_PTR data
)
1939 DWORD time_end
= data
;
1940 DWORD time_now
= GetTickCount();
1943 if (time_end
== INFINITE
)
1947 else if (time_end
> time_now
)
1949 wait
= time_end
- time_now
;
1954 return IBaseFilter_GetState(pFilter
, wait
, &state
);
1958 static HRESULT
SendFilterMessage(IFilterGraphImpl
*This
, fnFoundFilter FoundFilter
, DWORD_PTR data
)
1961 IBaseFilter
* pfilter
;
1968 TRACE("(%p)->()\n", This
);
1970 /* Explorer the graph from source filters to renderers, determine renderers
1971 * number and run filters from renderers to source filters */
1972 This
->nRenderers
= 0;
1973 ResetEvent(This
->hEventCompletion
);
1975 for(i
= 0; i
< This
->nFilters
; i
++)
1978 pfilter
= This
->ppFiltersInGraph
[i
];
1979 hr
= IBaseFilter_EnumPins(pfilter
, &pEnum
);
1982 WARN("Enum pins failed %x\n", hr
);
1985 /* Check if it is a source filter */
1986 while(IEnumPins_Next(pEnum
, 1, &pPin
, &dummy
) == S_OK
)
1988 IPin_QueryDirection(pPin
, &dir
);
1990 if (dir
== PINDIR_INPUT
)
1998 TRACE("Found a source filter %p\n", pfilter
);
1999 IEnumPins_Reset(pEnum
);
2000 while(IEnumPins_Next(pEnum
, 1, &pPin
, &dummy
) == S_OK
)
2002 /* Explore the graph downstream from this pin */
2003 ExploreGraph(This
, pPin
, FoundFilter
, data
);
2006 FoundFilter(pfilter
, data
);
2008 IEnumPins_Release(pEnum
);
2014 /*** IMediaControl methods ***/
2015 static HRESULT WINAPI
MediaControl_Run(IMediaControl
*iface
)
2017 IFilterGraphImpl
*This
= impl_from_IMediaControl(iface
);
2019 TRACE("(%p/%p)->()\n", This
, iface
);
2021 EnterCriticalSection(&This
->cs
);
2022 if (This
->state
== State_Running
)
2024 This
->EcCompleteCount
= 0;
2026 if (This
->defaultclock
&& !This
->refClock
)
2027 IFilterGraph2_SetDefaultSyncSource(&This
->IFilterGraph2_iface
);
2032 IReferenceClock_GetTime(This
->refClock
, &now
);
2033 if (This
->state
== State_Stopped
)
2034 This
->start_time
= now
+ 500000;
2035 else if (This
->pause_time
>= 0)
2036 This
->start_time
+= now
- This
->pause_time
;
2038 This
->start_time
= now
;
2040 else This
->start_time
= 0;
2042 SendFilterMessage(This
, SendRun
, (DWORD_PTR
)&This
->start_time
);
2043 This
->state
= State_Running
;
2045 LeaveCriticalSection(&This
->cs
);
2049 static HRESULT WINAPI
MediaControl_Pause(IMediaControl
*iface
)
2051 IFilterGraphImpl
*This
= impl_from_IMediaControl(iface
);
2053 TRACE("(%p/%p)->()\n", This
, iface
);
2055 EnterCriticalSection(&This
->cs
);
2056 if (This
->state
== State_Paused
)
2059 if (This
->state
== State_Running
&& This
->refClock
&& This
->start_time
>= 0)
2060 IReferenceClock_GetTime(This
->refClock
, &This
->pause_time
);
2062 This
->pause_time
= -1;
2064 SendFilterMessage(This
, SendPause
, 0);
2065 This
->state
= State_Paused
;
2067 LeaveCriticalSection(&This
->cs
);
2071 static HRESULT WINAPI
MediaControl_Stop(IMediaControl
*iface
)
2073 IFilterGraphImpl
*This
= impl_from_IMediaControl(iface
);
2075 TRACE("(%p/%p)->()\n", This
, iface
);
2077 if (This
->state
== State_Stopped
) return S_OK
;
2079 EnterCriticalSection(&This
->cs
);
2080 if (This
->state
== State_Running
) SendFilterMessage(This
, SendPause
, 0);
2081 SendFilterMessage(This
, SendStop
, 0);
2082 This
->state
= State_Stopped
;
2083 LeaveCriticalSection(&This
->cs
);
2087 static HRESULT WINAPI
MediaControl_GetState(IMediaControl
*iface
, LONG msTimeout
,
2090 IFilterGraphImpl
*This
= impl_from_IMediaControl(iface
);
2093 TRACE("(%p/%p)->(%d, %p)\n", This
, iface
, msTimeout
, pfs
);
2098 EnterCriticalSection(&This
->cs
);
2103 end
= GetTickCount() + msTimeout
;
2105 else if (msTimeout
< 0)
2114 SendFilterMessage(This
, SendGetState
, end
);
2116 LeaveCriticalSection(&This
->cs
);
2121 static HRESULT WINAPI
MediaControl_RenderFile(IMediaControl
*iface
, BSTR strFilename
)
2123 IFilterGraphImpl
*This
= impl_from_IMediaControl(iface
);
2125 TRACE("(%p/%p)->(%s (%p))\n", This
, iface
, debugstr_w(strFilename
), strFilename
);
2127 return IFilterGraph2_RenderFile(&This
->IFilterGraph2_iface
, strFilename
, NULL
);
2130 static HRESULT WINAPI
MediaControl_AddSourceFilter(IMediaControl
*iface
, BSTR strFilename
,
2133 IFilterGraphImpl
*This
= impl_from_IMediaControl(iface
);
2135 FIXME("(%p/%p)->(%s (%p), %p): stub !!!\n", This
, iface
, debugstr_w(strFilename
), strFilename
, ppUnk
);
2140 static HRESULT WINAPI
MediaControl_get_FilterCollection(IMediaControl
*iface
, IDispatch
**ppUnk
)
2142 IFilterGraphImpl
*This
= impl_from_IMediaControl(iface
);
2144 FIXME("(%p/%p)->(%p): stub !!!\n", This
, iface
, ppUnk
);
2149 static HRESULT WINAPI
MediaControl_get_RegFilterCollection(IMediaControl
*iface
, IDispatch
**ppUnk
)
2151 IFilterGraphImpl
*This
= impl_from_IMediaControl(iface
);
2153 FIXME("(%p/%p)->(%p): stub !!!\n", This
, iface
, ppUnk
);
2158 static HRESULT WINAPI
MediaControl_StopWhenReady(IMediaControl
*iface
)
2160 IFilterGraphImpl
*This
= impl_from_IMediaControl(iface
);
2162 FIXME("(%p/%p)->(): stub !!!\n", This
, iface
);
2168 static const IMediaControlVtbl IMediaControl_VTable
=
2170 MediaControl_QueryInterface
,
2171 MediaControl_AddRef
,
2172 MediaControl_Release
,
2173 MediaControl_GetTypeInfoCount
,
2174 MediaControl_GetTypeInfo
,
2175 MediaControl_GetIDsOfNames
,
2176 MediaControl_Invoke
,
2180 MediaControl_GetState
,
2181 MediaControl_RenderFile
,
2182 MediaControl_AddSourceFilter
,
2183 MediaControl_get_FilterCollection
,
2184 MediaControl_get_RegFilterCollection
,
2185 MediaControl_StopWhenReady
2188 static inline IFilterGraphImpl
*impl_from_IMediaSeeking(IMediaSeeking
*iface
)
2190 return CONTAINING_RECORD(iface
, IFilterGraphImpl
, IMediaSeeking_iface
);
2193 static HRESULT WINAPI
MediaSeeking_QueryInterface(IMediaSeeking
*iface
, REFIID riid
, void **ppvObj
)
2195 IFilterGraphImpl
*This
= impl_from_IMediaSeeking(iface
);
2197 TRACE("(%p/%p)->(%s (%p), %p)\n", This
, iface
, debugstr_guid(riid
), riid
, ppvObj
);
2199 return IUnknown_QueryInterface(This
->outer_unk
, riid
, ppvObj
);
2202 static ULONG WINAPI
MediaSeeking_AddRef(IMediaSeeking
*iface
)
2204 IFilterGraphImpl
*This
= impl_from_IMediaSeeking(iface
);
2206 TRACE("(%p/%p)->()\n", This
, iface
);
2208 return IUnknown_AddRef(This
->outer_unk
);
2211 static ULONG WINAPI
MediaSeeking_Release(IMediaSeeking
*iface
)
2213 IFilterGraphImpl
*This
= impl_from_IMediaSeeking(iface
);
2215 TRACE("(%p/%p)->()\n", This
, iface
);
2217 return IUnknown_Release(This
->outer_unk
);
2220 typedef HRESULT (WINAPI
*fnFoundSeek
)(IFilterGraphImpl
*This
, IMediaSeeking
*, DWORD_PTR arg
);
2222 static HRESULT
all_renderers_seek(IFilterGraphImpl
*This
, fnFoundSeek FoundSeek
, DWORD_PTR arg
) {
2223 BOOL allnotimpl
= TRUE
;
2225 HRESULT hr
, hr_return
= S_OK
;
2227 TRACE("(%p)->(%p %08lx)\n", This
, FoundSeek
, arg
);
2228 /* Send a message to all renderers, they are responsible for broadcasting it further */
2230 for(i
= 0; i
< This
->nFilters
; i
++)
2232 IMediaSeeking
*seek
= NULL
;
2233 IBaseFilter
* pfilter
= This
->ppFiltersInGraph
[i
];
2234 IAMFilterMiscFlags
*flags
= NULL
;
2236 IBaseFilter_QueryInterface(pfilter
, &IID_IAMFilterMiscFlags
, (void**)&flags
);
2239 filterflags
= IAMFilterMiscFlags_GetMiscFlags(flags
);
2240 IAMFilterMiscFlags_Release(flags
);
2241 if (filterflags
!= AM_FILTER_MISC_FLAGS_IS_RENDERER
)
2244 IBaseFilter_QueryInterface(pfilter
, &IID_IMediaSeeking
, (void**)&seek
);
2247 hr
= FoundSeek(This
, seek
, arg
);
2248 IMediaSeeking_Release(seek
);
2249 if (hr_return
!= E_NOTIMPL
)
2251 if (hr_return
== S_OK
|| (FAILED(hr
) && hr
!= E_NOTIMPL
&& SUCCEEDED(hr_return
)))
2260 static HRESULT WINAPI
FoundCapabilities(IFilterGraphImpl
*This
, IMediaSeeking
*seek
, DWORD_PTR pcaps
)
2265 hr
= IMediaSeeking_GetCapabilities(seek
, &caps
);
2269 /* Only add common capabilities everything supports */
2270 *(DWORD
*)pcaps
&= caps
;
2275 /*** IMediaSeeking methods ***/
2276 static HRESULT WINAPI
MediaSeeking_GetCapabilities(IMediaSeeking
*iface
, DWORD
*pCapabilities
)
2278 IFilterGraphImpl
*This
= impl_from_IMediaSeeking(iface
);
2281 TRACE("(%p/%p)->(%p)\n", This
, iface
, pCapabilities
);
2286 EnterCriticalSection(&This
->cs
);
2287 *pCapabilities
= 0xffffffff;
2289 hr
= all_renderers_seek(This
, FoundCapabilities
, (DWORD_PTR
)pCapabilities
);
2290 LeaveCriticalSection(&This
->cs
);
2295 static HRESULT WINAPI
MediaSeeking_CheckCapabilities(IMediaSeeking
*iface
, DWORD
*pCapabilities
)
2297 IFilterGraphImpl
*This
= impl_from_IMediaSeeking(iface
);
2301 TRACE("(%p/%p)->(%p)\n", This
, iface
, pCapabilities
);
2306 EnterCriticalSection(&This
->cs
);
2307 originalcaps
= *pCapabilities
;
2308 hr
= all_renderers_seek(This
, FoundCapabilities
, (DWORD_PTR
)pCapabilities
);
2309 LeaveCriticalSection(&This
->cs
);
2314 if (!*pCapabilities
)
2316 if (*pCapabilities
!= originalcaps
)
2321 static HRESULT WINAPI
MediaSeeking_IsFormatSupported(IMediaSeeking
*iface
, const GUID
*pFormat
)
2323 IFilterGraphImpl
*This
= impl_from_IMediaSeeking(iface
);
2328 TRACE("(%p/%p)->(%s)\n", This
, iface
, debugstr_guid(pFormat
));
2330 if (!IsEqualGUID(&TIME_FORMAT_MEDIA_TIME
, pFormat
))
2332 FIXME("Unhandled time format %s\n", debugstr_guid(pFormat
));
2339 static HRESULT WINAPI
MediaSeeking_QueryPreferredFormat(IMediaSeeking
*iface
, GUID
*pFormat
)
2341 IFilterGraphImpl
*This
= impl_from_IMediaSeeking(iface
);
2346 FIXME("(%p/%p)->(%p): semi-stub !!!\n", This
, iface
, pFormat
);
2347 memcpy(pFormat
, &TIME_FORMAT_MEDIA_TIME
, sizeof(GUID
));
2352 static HRESULT WINAPI
MediaSeeking_GetTimeFormat(IMediaSeeking
*iface
, GUID
*pFormat
)
2354 IFilterGraphImpl
*This
= impl_from_IMediaSeeking(iface
);
2359 TRACE("(%p/%p)->(%p)\n", This
, iface
, pFormat
);
2360 memcpy(pFormat
, &This
->timeformatseek
, sizeof(GUID
));
2365 static HRESULT WINAPI
MediaSeeking_IsUsingTimeFormat(IMediaSeeking
*iface
, const GUID
*pFormat
)
2367 IFilterGraphImpl
*This
= impl_from_IMediaSeeking(iface
);
2369 TRACE("(%p/%p)->(%p)\n", This
, iface
, pFormat
);
2373 if (memcmp(pFormat
, &This
->timeformatseek
, sizeof(GUID
)))
2379 static HRESULT WINAPI
MediaSeeking_SetTimeFormat(IMediaSeeking
*iface
, const GUID
*pFormat
)
2381 IFilterGraphImpl
*This
= impl_from_IMediaSeeking(iface
);
2386 TRACE("(%p/%p)->(%s)\n", This
, iface
, debugstr_guid(pFormat
));
2388 if (This
->state
!= State_Stopped
)
2389 return VFW_E_WRONG_STATE
;
2391 if (!IsEqualGUID(&TIME_FORMAT_MEDIA_TIME
, pFormat
))
2393 FIXME("Unhandled time format %s\n", debugstr_guid(pFormat
));
2394 return E_INVALIDARG
;
2400 static HRESULT WINAPI
FoundDuration(IFilterGraphImpl
*This
, IMediaSeeking
*seek
, DWORD_PTR pduration
)
2403 LONGLONG duration
= 0, *pdur
= (LONGLONG
*)pduration
;
2405 hr
= IMediaSeeking_GetDuration(seek
, &duration
);
2409 if (*pdur
< duration
)
2414 static HRESULT WINAPI
MediaSeeking_GetDuration(IMediaSeeking
*iface
, LONGLONG
*pDuration
)
2416 IFilterGraphImpl
*This
= impl_from_IMediaSeeking(iface
);
2419 TRACE("(%p/%p)->(%p)\n", This
, iface
, pDuration
);
2424 EnterCriticalSection(&This
->cs
);
2426 hr
= all_renderers_seek(This
, FoundDuration
, (DWORD_PTR
)pDuration
);
2427 LeaveCriticalSection(&This
->cs
);
2429 TRACE("--->%08x\n", hr
);
2433 static HRESULT WINAPI
MediaSeeking_ConvertTimeFormat(IMediaSeeking
*iface
, LONGLONG
*pTarget
,
2434 const GUID
*pTargetFormat
, LONGLONG Source
, const GUID
*pSourceFormat
)
2436 IFilterGraphImpl
*This
= impl_from_IMediaSeeking(iface
);
2438 TRACE("(%p/%p)->(%p, %s, 0x%s, %s)\n", This
, iface
, pTarget
,
2439 debugstr_guid(pTargetFormat
), wine_dbgstr_longlong(Source
), debugstr_guid(pSourceFormat
));
2442 pSourceFormat
= &This
->timeformatseek
;
2444 if (IsEqualGUID(pTargetFormat
, pSourceFormat
))
2447 FIXME("conversion %s->%s not supported\n", debugstr_guid(pSourceFormat
), debugstr_guid(pTargetFormat
));
2453 LONGLONG
* current
, *stop
;
2454 DWORD curflags
, stopflags
;
2457 static HRESULT WINAPI
found_setposition(IFilterGraphImpl
*This
, IMediaSeeking
*seek
, DWORD_PTR pargs
)
2459 struct pos_args
*args
= (void*)pargs
;
2461 return IMediaSeeking_SetPositions(seek
, args
->current
, args
->curflags
, args
->stop
, args
->stopflags
);
2464 static HRESULT WINAPI
MediaSeeking_SetPositions(IMediaSeeking
*iface
, LONGLONG
*pCurrent
,
2465 DWORD dwCurrentFlags
, LONGLONG
*pStop
, DWORD dwStopFlags
)
2467 IFilterGraphImpl
*This
= impl_from_IMediaSeeking(iface
);
2470 struct pos_args args
;
2472 TRACE("(%p/%p)->(%p, %08x, %p, %08x)\n", This
, iface
, pCurrent
, dwCurrentFlags
, pStop
, dwStopFlags
);
2474 EnterCriticalSection(&This
->cs
);
2475 state
= This
->state
;
2476 TRACE("State: %s\n", state
== State_Running
? "Running" : (state
== State_Paused
? "Paused" : (state
== State_Stopped
? "Stopped" : "UNKNOWN")));
2478 if ((dwCurrentFlags
& 0x7) != AM_SEEKING_AbsolutePositioning
&&
2479 (dwCurrentFlags
& 0x7) != AM_SEEKING_NoPositioning
)
2480 FIXME("Adjust method %x not handled yet!\n", dwCurrentFlags
& 0x7);
2482 if (state
== State_Running
&& !(dwCurrentFlags
& AM_SEEKING_NoFlush
))
2483 IMediaControl_Pause(&This
->IMediaControl_iface
);
2484 args
.current
= pCurrent
;
2486 args
.curflags
= dwCurrentFlags
;
2487 args
.stopflags
= dwStopFlags
;
2488 hr
= all_renderers_seek(This
, found_setposition
, (DWORD_PTR
)&args
);
2490 if ((dwCurrentFlags
& 0x7) != AM_SEEKING_NoPositioning
)
2491 This
->pause_time
= This
->start_time
= -1;
2492 if (state
== State_Running
&& !(dwCurrentFlags
& AM_SEEKING_NoFlush
))
2493 IMediaControl_Run(&This
->IMediaControl_iface
);
2494 LeaveCriticalSection(&This
->cs
);
2499 static HRESULT WINAPI
found_getposition(IFilterGraphImpl
*This
, IMediaSeeking
*seek
, DWORD_PTR pargs
)
2501 struct pos_args
*args
= (void*)pargs
;
2503 return IMediaSeeking_GetPositions(seek
, args
->current
, args
->stop
);
2506 static HRESULT WINAPI
MediaSeeking_GetPositions(IMediaSeeking
*iface
, LONGLONG
*pCurrent
,
2509 IFilterGraphImpl
*This
= impl_from_IMediaSeeking(iface
);
2510 struct pos_args args
;
2514 TRACE("(%p/%p)->(%p, %p)\n", This
, iface
, pCurrent
, pStop
);
2516 args
.current
= pCurrent
;
2518 EnterCriticalSection(&This
->cs
);
2519 hr
= all_renderers_seek(This
, found_getposition
, (DWORD_PTR
)&args
);
2520 if (This
->state
== State_Running
&& This
->refClock
&& This
->start_time
>= 0)
2522 IReferenceClock_GetTime(This
->refClock
, &time
);
2524 time
-= This
->start_time
;
2526 if (This
->pause_time
> 0)
2527 time
+= This
->pause_time
;
2529 LeaveCriticalSection(&This
->cs
);
2534 static HRESULT WINAPI
MediaSeeking_GetCurrentPosition(IMediaSeeking
*iface
, LONGLONG
*pCurrent
)
2542 hr
= MediaSeeking_GetPositions(iface
, pCurrent
, &time
);
2544 TRACE("Time: %u.%03u\n", (DWORD
)(*pCurrent
/ 10000000), (DWORD
)((*pCurrent
/ 10000)%1000));
2549 static HRESULT WINAPI
MediaSeeking_GetStopPosition(IMediaSeeking
*iface
, LONGLONG
*pStop
)
2551 IFilterGraphImpl
*This
= impl_from_IMediaSeeking(iface
);
2555 TRACE("(%p/%p)->(%p)\n", This
, iface
, pStop
);
2560 hr
= MediaSeeking_GetPositions(iface
, &time
, pStop
);
2565 static HRESULT WINAPI
MediaSeeking_GetAvailable(IMediaSeeking
*iface
, LONGLONG
*pEarliest
,
2568 IFilterGraphImpl
*This
= impl_from_IMediaSeeking(iface
);
2570 FIXME("(%p/%p)->(%p, %p): stub !!!\n", This
, iface
, pEarliest
, pLatest
);
2575 static HRESULT WINAPI
MediaSeeking_SetRate(IMediaSeeking
*iface
, double dRate
)
2577 IFilterGraphImpl
*This
= impl_from_IMediaSeeking(iface
);
2579 FIXME("(%p/%p)->(%f): stub !!!\n", This
, iface
, dRate
);
2584 static HRESULT WINAPI
MediaSeeking_GetRate(IMediaSeeking
*iface
, double *pdRate
)
2586 IFilterGraphImpl
*This
= impl_from_IMediaSeeking(iface
);
2588 FIXME("(%p/%p)->(%p): stub !!!\n", This
, iface
, pdRate
);
2593 static HRESULT WINAPI
MediaSeeking_GetPreroll(IMediaSeeking
*iface
, LONGLONG
*pllPreroll
)
2595 IFilterGraphImpl
*This
= impl_from_IMediaSeeking(iface
);
2597 FIXME("(%p/%p)->(%p): stub !!!\n", This
, iface
, pllPreroll
);
2603 static const IMediaSeekingVtbl IMediaSeeking_VTable
=
2605 MediaSeeking_QueryInterface
,
2606 MediaSeeking_AddRef
,
2607 MediaSeeking_Release
,
2608 MediaSeeking_GetCapabilities
,
2609 MediaSeeking_CheckCapabilities
,
2610 MediaSeeking_IsFormatSupported
,
2611 MediaSeeking_QueryPreferredFormat
,
2612 MediaSeeking_GetTimeFormat
,
2613 MediaSeeking_IsUsingTimeFormat
,
2614 MediaSeeking_SetTimeFormat
,
2615 MediaSeeking_GetDuration
,
2616 MediaSeeking_GetStopPosition
,
2617 MediaSeeking_GetCurrentPosition
,
2618 MediaSeeking_ConvertTimeFormat
,
2619 MediaSeeking_SetPositions
,
2620 MediaSeeking_GetPositions
,
2621 MediaSeeking_GetAvailable
,
2622 MediaSeeking_SetRate
,
2623 MediaSeeking_GetRate
,
2624 MediaSeeking_GetPreroll
2627 static inline IFilterGraphImpl
*impl_from_IMediaPosition(IMediaPosition
*iface
)
2629 return CONTAINING_RECORD(iface
, IFilterGraphImpl
, IMediaPosition_iface
);
2632 /*** IUnknown methods ***/
2633 static HRESULT WINAPI
MediaPosition_QueryInterface(IMediaPosition
* iface
, REFIID riid
, void** ppvObj
)
2635 IFilterGraphImpl
*This
= impl_from_IMediaPosition( iface
);
2637 TRACE("(%p/%p)->(%s (%p), %p)\n", This
, iface
, debugstr_guid(riid
), riid
, ppvObj
);
2639 return IUnknown_QueryInterface(This
->outer_unk
, riid
, ppvObj
);
2642 static ULONG WINAPI
MediaPosition_AddRef(IMediaPosition
*iface
)
2644 IFilterGraphImpl
*This
= impl_from_IMediaPosition( iface
);
2646 TRACE("(%p/%p)->()\n", This
, iface
);
2648 return IUnknown_AddRef(This
->outer_unk
);
2651 static ULONG WINAPI
MediaPosition_Release(IMediaPosition
*iface
)
2653 IFilterGraphImpl
*This
= impl_from_IMediaPosition( iface
);
2655 TRACE("(%p/%p)->()\n", This
, iface
);
2657 return IUnknown_Release(This
->outer_unk
);
2660 /*** IDispatch methods ***/
2661 static HRESULT WINAPI
MediaPosition_GetTypeInfoCount(IMediaPosition
*iface
, UINT
* pctinfo
)
2663 FIXME("(%p) stub!\n", iface
);
2667 static HRESULT WINAPI
MediaPosition_GetTypeInfo(IMediaPosition
*iface
, UINT iTInfo
, LCID lcid
, ITypeInfo
** ppTInfo
)
2669 FIXME("(%p) stub!\n", iface
);
2673 static HRESULT WINAPI
MediaPosition_GetIDsOfNames(IMediaPosition
* iface
, REFIID riid
, LPOLESTR
* rgszNames
, UINT cNames
, LCID lcid
, DISPID
* rgDispId
)
2675 FIXME("(%p) stub!\n", iface
);
2679 static HRESULT WINAPI
MediaPosition_Invoke(IMediaPosition
* iface
, DISPID dispIdMember
, REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
* pDispParams
, VARIANT
* pVarResult
, EXCEPINFO
* pExcepInfo
, UINT
* puArgErr
)
2681 FIXME("(%p) stub!\n", iface
);
2685 static HRESULT
ConvertFromREFTIME(IMediaSeeking
*seek
, REFTIME time_in
, LONGLONG
*time_out
)
2690 hr
= MediaSeeking_GetTimeFormat(seek
, &time_format
);
2693 if (!IsEqualGUID(&TIME_FORMAT_MEDIA_TIME
, &time_format
))
2695 FIXME("Unsupported time format.\n");
2699 *time_out
= (LONGLONG
) (time_in
* 10000000); /* convert from 1 second intervals to 100 ns intervals */
2703 static HRESULT
ConvertToREFTIME(IMediaSeeking
*seek
, LONGLONG time_in
, REFTIME
*time_out
)
2708 hr
= MediaSeeking_GetTimeFormat(seek
, &time_format
);
2711 if (!IsEqualGUID(&TIME_FORMAT_MEDIA_TIME
, &time_format
))
2713 FIXME("Unsupported time format.\n");
2717 *time_out
= (REFTIME
)time_in
/ 10000000; /* convert from 100 ns intervals to 1 second intervals */
2721 /*** IMediaPosition methods ***/
2722 static HRESULT WINAPI
MediaPosition_get_Duration(IMediaPosition
* iface
, REFTIME
*plength
)
2725 IFilterGraphImpl
*This
= impl_from_IMediaPosition( iface
);
2726 HRESULT hr
= IMediaSeeking_GetDuration(&This
->IMediaSeeking_iface
, &duration
);
2729 return ConvertToREFTIME(&This
->IMediaSeeking_iface
, duration
, plength
);
2732 static HRESULT WINAPI
MediaPosition_put_CurrentPosition(IMediaPosition
* iface
, REFTIME llTime
)
2734 IFilterGraphImpl
*This
= impl_from_IMediaPosition( iface
);
2738 hr
= ConvertFromREFTIME(&This
->IMediaSeeking_iface
, llTime
, &reftime
);
2741 return IMediaSeeking_SetPositions(&This
->IMediaSeeking_iface
, &reftime
,
2742 AM_SEEKING_AbsolutePositioning
, NULL
, AM_SEEKING_NoPositioning
);
2745 static HRESULT WINAPI
MediaPosition_get_CurrentPosition(IMediaPosition
* iface
, REFTIME
*pllTime
)
2747 IFilterGraphImpl
*This
= impl_from_IMediaPosition( iface
);
2751 hr
= IMediaSeeking_GetCurrentPosition(&This
->IMediaSeeking_iface
, &pos
);
2754 return ConvertToREFTIME(&This
->IMediaSeeking_iface
, pos
, pllTime
);
2757 static HRESULT WINAPI
MediaPosition_get_StopTime(IMediaPosition
* iface
, REFTIME
*pllTime
)
2759 IFilterGraphImpl
*This
= impl_from_IMediaPosition( iface
);
2761 HRESULT hr
= IMediaSeeking_GetStopPosition(&This
->IMediaSeeking_iface
, &pos
);
2764 return ConvertToREFTIME(&This
->IMediaSeeking_iface
, pos
, pllTime
);
2767 static HRESULT WINAPI
MediaPosition_put_StopTime(IMediaPosition
* iface
, REFTIME llTime
)
2769 IFilterGraphImpl
*This
= impl_from_IMediaPosition( iface
);
2773 hr
= ConvertFromREFTIME(&This
->IMediaSeeking_iface
, llTime
, &reftime
);
2776 return IMediaSeeking_SetPositions(&This
->IMediaSeeking_iface
, NULL
, AM_SEEKING_NoPositioning
,
2777 &reftime
, AM_SEEKING_AbsolutePositioning
);
2780 static HRESULT WINAPI
MediaPosition_get_PrerollTime(IMediaPosition
* iface
, REFTIME
*pllTime
)
2782 FIXME("(%p)->(%p) stub!\n", iface
, pllTime
);
2786 static HRESULT WINAPI
MediaPosition_put_PrerollTime(IMediaPosition
* iface
, REFTIME llTime
)
2788 FIXME("(%p)->(%f) stub!\n", iface
, llTime
);
2792 static HRESULT WINAPI
MediaPosition_put_Rate(IMediaPosition
* iface
, double dRate
)
2794 IFilterGraphImpl
*This
= impl_from_IMediaPosition( iface
);
2795 return IMediaSeeking_SetRate(&This
->IMediaSeeking_iface
, dRate
);
2798 static HRESULT WINAPI
MediaPosition_get_Rate(IMediaPosition
* iface
, double *pdRate
)
2800 IFilterGraphImpl
*This
= impl_from_IMediaPosition( iface
);
2801 return IMediaSeeking_GetRate(&This
->IMediaSeeking_iface
, pdRate
);
2804 static HRESULT WINAPI
MediaPosition_CanSeekForward(IMediaPosition
* iface
, LONG
*pCanSeekForward
)
2806 FIXME("(%p)->(%p) stub!\n", iface
, pCanSeekForward
);
2810 static HRESULT WINAPI
MediaPosition_CanSeekBackward(IMediaPosition
* iface
, LONG
*pCanSeekBackward
)
2812 FIXME("(%p)->(%p) stub!\n", iface
, pCanSeekBackward
);
2817 static const IMediaPositionVtbl IMediaPosition_VTable
=
2819 MediaPosition_QueryInterface
,
2820 MediaPosition_AddRef
,
2821 MediaPosition_Release
,
2822 MediaPosition_GetTypeInfoCount
,
2823 MediaPosition_GetTypeInfo
,
2824 MediaPosition_GetIDsOfNames
,
2825 MediaPosition_Invoke
,
2826 MediaPosition_get_Duration
,
2827 MediaPosition_put_CurrentPosition
,
2828 MediaPosition_get_CurrentPosition
,
2829 MediaPosition_get_StopTime
,
2830 MediaPosition_put_StopTime
,
2831 MediaPosition_get_PrerollTime
,
2832 MediaPosition_put_PrerollTime
,
2833 MediaPosition_put_Rate
,
2834 MediaPosition_get_Rate
,
2835 MediaPosition_CanSeekForward
,
2836 MediaPosition_CanSeekBackward
2839 static inline IFilterGraphImpl
*impl_from_IObjectWithSite(IObjectWithSite
*iface
)
2841 return CONTAINING_RECORD(iface
, IFilterGraphImpl
, IObjectWithSite_iface
);
2844 /*** IUnknown methods ***/
2845 static HRESULT WINAPI
ObjectWithSite_QueryInterface(IObjectWithSite
* iface
, REFIID riid
, void** ppvObj
)
2847 IFilterGraphImpl
*This
= impl_from_IObjectWithSite( iface
);
2849 TRACE("(%p/%p)->(%s (%p), %p)\n", This
, iface
, debugstr_guid(riid
), riid
, ppvObj
);
2851 return IUnknown_QueryInterface(This
->outer_unk
, riid
, ppvObj
);
2854 static ULONG WINAPI
ObjectWithSite_AddRef(IObjectWithSite
*iface
)
2856 IFilterGraphImpl
*This
= impl_from_IObjectWithSite( iface
);
2858 TRACE("(%p/%p)->()\n", This
, iface
);
2860 return IUnknown_AddRef(This
->outer_unk
);
2863 static ULONG WINAPI
ObjectWithSite_Release(IObjectWithSite
*iface
)
2865 IFilterGraphImpl
*This
= impl_from_IObjectWithSite( iface
);
2867 TRACE("(%p/%p)->()\n", This
, iface
);
2869 return IUnknown_Release(This
->outer_unk
);
2872 /*** IObjectWithSite methods ***/
2874 static HRESULT WINAPI
ObjectWithSite_SetSite(IObjectWithSite
*iface
, IUnknown
*pUnkSite
)
2876 IFilterGraphImpl
*This
= impl_from_IObjectWithSite( iface
);
2878 TRACE("(%p/%p)->()\n", This
, iface
);
2879 if (This
->pSite
) IUnknown_Release(This
->pSite
);
2880 This
->pSite
= pUnkSite
;
2881 IUnknown_AddRef(This
->pSite
);
2885 static HRESULT WINAPI
ObjectWithSite_GetSite(IObjectWithSite
*iface
, REFIID riid
, PVOID
*ppvSite
)
2887 IFilterGraphImpl
*This
= impl_from_IObjectWithSite( iface
);
2889 TRACE("(%p/%p)->(%s)\n", This
, iface
,debugstr_guid(riid
));
2895 return IUnknown_QueryInterface(This
->pSite
, riid
, ppvSite
);
2898 static const IObjectWithSiteVtbl IObjectWithSite_VTable
=
2900 ObjectWithSite_QueryInterface
,
2901 ObjectWithSite_AddRef
,
2902 ObjectWithSite_Release
,
2903 ObjectWithSite_SetSite
,
2904 ObjectWithSite_GetSite
,
2907 static HRESULT
GetTargetInterface(IFilterGraphImpl
* pGraph
, REFIID riid
, LPVOID
* ppvObj
)
2909 HRESULT hr
= E_NOINTERFACE
;
2913 /* Check if the interface type is already registered */
2914 for (entry
= 0; entry
< pGraph
->nItfCacheEntries
; entry
++)
2915 if (riid
== pGraph
->ItfCacheEntries
[entry
].riid
)
2917 if (pGraph
->ItfCacheEntries
[entry
].iface
)
2919 /* Return the interface if available */
2920 *ppvObj
= pGraph
->ItfCacheEntries
[entry
].iface
;
2926 if (entry
>= MAX_ITF_CACHE_ENTRIES
)
2928 FIXME("Not enough space to store interface in the cache\n");
2929 return E_OUTOFMEMORY
;
2932 /* Find a filter supporting the requested interface */
2933 for (i
= 0; i
< pGraph
->nFilters
; i
++)
2935 hr
= IBaseFilter_QueryInterface(pGraph
->ppFiltersInGraph
[i
], riid
, ppvObj
);
2938 pGraph
->ItfCacheEntries
[entry
].riid
= riid
;
2939 pGraph
->ItfCacheEntries
[entry
].filter
= pGraph
->ppFiltersInGraph
[i
];
2940 pGraph
->ItfCacheEntries
[entry
].iface
= *ppvObj
;
2941 if (entry
>= pGraph
->nItfCacheEntries
)
2942 pGraph
->nItfCacheEntries
++;
2945 if (hr
!= E_NOINTERFACE
)
2952 static inline IFilterGraphImpl
*impl_from_IBasicAudio(IBasicAudio
*iface
)
2954 return CONTAINING_RECORD(iface
, IFilterGraphImpl
, IBasicAudio_iface
);
2957 static HRESULT WINAPI
BasicAudio_QueryInterface(IBasicAudio
*iface
, REFIID riid
, void **ppvObj
)
2959 IFilterGraphImpl
*This
= impl_from_IBasicAudio(iface
);
2961 TRACE("(%p/%p)->(%s (%p), %p)\n", This
, iface
, debugstr_guid(riid
), riid
, ppvObj
);
2963 return IUnknown_QueryInterface(This
->outer_unk
, riid
, ppvObj
);
2966 static ULONG WINAPI
BasicAudio_AddRef(IBasicAudio
*iface
)
2968 IFilterGraphImpl
*This
= impl_from_IBasicAudio(iface
);
2970 TRACE("(%p/%p)->()\n", This
, iface
);
2972 return IUnknown_AddRef(This
->outer_unk
);
2975 static ULONG WINAPI
BasicAudio_Release(IBasicAudio
*iface
)
2977 IFilterGraphImpl
*This
= impl_from_IBasicAudio(iface
);
2979 TRACE("(%p/%p)->()\n", This
, iface
);
2981 return IUnknown_Release(This
->outer_unk
);
2984 /*** IDispatch methods ***/
2985 static HRESULT WINAPI
BasicAudio_GetTypeInfoCount(IBasicAudio
*iface
, UINT
*pctinfo
)
2987 IFilterGraphImpl
*This
= impl_from_IBasicAudio(iface
);
2988 IBasicAudio
* pBasicAudio
;
2991 TRACE("(%p/%p)->(%p)\n", This
, iface
, pctinfo
);
2993 EnterCriticalSection(&This
->cs
);
2995 hr
= GetTargetInterface(This
, &IID_IBasicAudio
, (LPVOID
*)&pBasicAudio
);
2998 hr
= IBasicAudio_GetTypeInfoCount(pBasicAudio
, pctinfo
);
3000 LeaveCriticalSection(&This
->cs
);
3005 static HRESULT WINAPI
BasicAudio_GetTypeInfo(IBasicAudio
*iface
, UINT iTInfo
, LCID lcid
,
3006 ITypeInfo
**ppTInfo
)
3008 IFilterGraphImpl
*This
= impl_from_IBasicAudio(iface
);
3009 IBasicAudio
* pBasicAudio
;
3012 TRACE("(%p/%p)->(%d, %d, %p)\n", This
, iface
, iTInfo
, lcid
, ppTInfo
);
3014 EnterCriticalSection(&This
->cs
);
3016 hr
= GetTargetInterface(This
, &IID_IBasicAudio
, (LPVOID
*)&pBasicAudio
);
3019 hr
= IBasicAudio_GetTypeInfo(pBasicAudio
, iTInfo
, lcid
, ppTInfo
);
3021 LeaveCriticalSection(&This
->cs
);
3026 static HRESULT WINAPI
BasicAudio_GetIDsOfNames(IBasicAudio
*iface
, REFIID riid
, LPOLESTR
*rgszNames
,
3027 UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
3029 IFilterGraphImpl
*This
= impl_from_IBasicAudio(iface
);
3030 IBasicAudio
* pBasicAudio
;
3033 TRACE("(%p/%p)->(%s (%p), %p, %d, %d, %p)\n", This
, iface
, debugstr_guid(riid
), riid
, rgszNames
, cNames
, lcid
, rgDispId
);
3035 EnterCriticalSection(&This
->cs
);
3037 hr
= GetTargetInterface(This
, &IID_IBasicAudio
, (LPVOID
*)&pBasicAudio
);
3040 hr
= IBasicAudio_GetIDsOfNames(pBasicAudio
, riid
, rgszNames
, cNames
, lcid
, rgDispId
);
3042 LeaveCriticalSection(&This
->cs
);
3047 static HRESULT WINAPI
BasicAudio_Invoke(IBasicAudio
*iface
, DISPID dispIdMember
, REFIID riid
,
3048 LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
, VARIANT
*pVarResult
, EXCEPINFO
*pExepInfo
,
3051 IFilterGraphImpl
*This
= impl_from_IBasicAudio(iface
);
3052 IBasicAudio
* pBasicAudio
;
3055 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
);
3057 EnterCriticalSection(&This
->cs
);
3059 hr
= GetTargetInterface(This
, &IID_IBasicAudio
, (LPVOID
*)&pBasicAudio
);
3062 hr
= IBasicAudio_Invoke(pBasicAudio
, dispIdMember
, riid
, lcid
, wFlags
, pDispParams
, pVarResult
, pExepInfo
, puArgErr
);
3064 LeaveCriticalSection(&This
->cs
);
3069 /*** IBasicAudio methods ***/
3070 static HRESULT WINAPI
BasicAudio_put_Volume(IBasicAudio
*iface
, LONG lVolume
)
3072 IFilterGraphImpl
*This
= impl_from_IBasicAudio(iface
);
3073 IBasicAudio
* pBasicAudio
;
3076 TRACE("(%p/%p)->(%d)\n", This
, iface
, lVolume
);
3078 EnterCriticalSection(&This
->cs
);
3080 hr
= GetTargetInterface(This
, &IID_IBasicAudio
, (LPVOID
*)&pBasicAudio
);
3083 hr
= IBasicAudio_put_Volume(pBasicAudio
, lVolume
);
3085 LeaveCriticalSection(&This
->cs
);
3090 static HRESULT WINAPI
BasicAudio_get_Volume(IBasicAudio
*iface
, LONG
*plVolume
)
3092 IFilterGraphImpl
*This
= impl_from_IBasicAudio(iface
);
3093 IBasicAudio
* pBasicAudio
;
3096 TRACE("(%p/%p)->(%p)\n", This
, iface
, plVolume
);
3098 EnterCriticalSection(&This
->cs
);
3100 hr
= GetTargetInterface(This
, &IID_IBasicAudio
, (LPVOID
*)&pBasicAudio
);
3103 hr
= IBasicAudio_get_Volume(pBasicAudio
, plVolume
);
3105 LeaveCriticalSection(&This
->cs
);
3110 static HRESULT WINAPI
BasicAudio_put_Balance(IBasicAudio
*iface
, LONG lBalance
)
3112 IFilterGraphImpl
*This
= impl_from_IBasicAudio(iface
);
3113 IBasicAudio
* pBasicAudio
;
3116 TRACE("(%p/%p)->(%d)\n", This
, iface
, lBalance
);
3118 EnterCriticalSection(&This
->cs
);
3120 hr
= GetTargetInterface(This
, &IID_IBasicAudio
, (LPVOID
*)&pBasicAudio
);
3123 hr
= IBasicAudio_put_Balance(pBasicAudio
, lBalance
);
3125 LeaveCriticalSection(&This
->cs
);
3130 static HRESULT WINAPI
BasicAudio_get_Balance(IBasicAudio
*iface
, LONG
*plBalance
)
3132 IFilterGraphImpl
*This
= impl_from_IBasicAudio(iface
);
3133 IBasicAudio
* pBasicAudio
;
3136 TRACE("(%p/%p)->(%p)\n", This
, iface
, plBalance
);
3138 EnterCriticalSection(&This
->cs
);
3140 hr
= GetTargetInterface(This
, &IID_IBasicAudio
, (LPVOID
*)&pBasicAudio
);
3143 hr
= IBasicAudio_get_Balance(pBasicAudio
, plBalance
);
3145 LeaveCriticalSection(&This
->cs
);
3150 static const IBasicAudioVtbl IBasicAudio_VTable
=
3152 BasicAudio_QueryInterface
,
3155 BasicAudio_GetTypeInfoCount
,
3156 BasicAudio_GetTypeInfo
,
3157 BasicAudio_GetIDsOfNames
,
3159 BasicAudio_put_Volume
,
3160 BasicAudio_get_Volume
,
3161 BasicAudio_put_Balance
,
3162 BasicAudio_get_Balance
3165 static inline IFilterGraphImpl
*impl_from_IBasicVideo2(IBasicVideo2
*iface
)
3167 return CONTAINING_RECORD(iface
, IFilterGraphImpl
, IBasicVideo2_iface
);
3170 static HRESULT WINAPI
BasicVideo_QueryInterface(IBasicVideo2
*iface
, REFIID riid
, void **ppvObj
)
3172 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3174 TRACE("(%p/%p)->(%s (%p), %p)\n", This
, iface
, debugstr_guid(riid
), riid
, ppvObj
);
3176 return IUnknown_QueryInterface(This
->outer_unk
, riid
, ppvObj
);
3179 static ULONG WINAPI
BasicVideo_AddRef(IBasicVideo2
*iface
)
3181 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3183 TRACE("(%p/%p)->()\n", This
, iface
);
3185 return IUnknown_AddRef(This
->outer_unk
);
3188 static ULONG WINAPI
BasicVideo_Release(IBasicVideo2
*iface
)
3190 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3192 TRACE("(%p/%p)->()\n", This
, iface
);
3194 return IUnknown_Release(This
->outer_unk
);
3197 /*** IDispatch methods ***/
3198 static HRESULT WINAPI
BasicVideo_GetTypeInfoCount(IBasicVideo2
*iface
, UINT
*pctinfo
)
3200 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3201 IBasicVideo
*pBasicVideo
;
3204 TRACE("(%p/%p)->(%p)\n", This
, iface
, pctinfo
);
3206 EnterCriticalSection(&This
->cs
);
3208 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3211 hr
= IBasicVideo_GetTypeInfoCount(pBasicVideo
, pctinfo
);
3213 LeaveCriticalSection(&This
->cs
);
3218 static HRESULT WINAPI
BasicVideo_GetTypeInfo(IBasicVideo2
*iface
, UINT iTInfo
, LCID lcid
,
3219 ITypeInfo
**ppTInfo
)
3221 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3222 IBasicVideo
*pBasicVideo
;
3225 TRACE("(%p/%p)->(%d, %d, %p)\n", This
, iface
, iTInfo
, lcid
, ppTInfo
);
3227 EnterCriticalSection(&This
->cs
);
3229 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3232 hr
= IBasicVideo_GetTypeInfo(pBasicVideo
, iTInfo
, lcid
, ppTInfo
);
3234 LeaveCriticalSection(&This
->cs
);
3239 static HRESULT WINAPI
BasicVideo_GetIDsOfNames(IBasicVideo2
*iface
, REFIID riid
,
3240 LPOLESTR
*rgszNames
, UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
3242 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3243 IBasicVideo
*pBasicVideo
;
3246 TRACE("(%p/%p)->(%s (%p), %p, %d, %d, %p)\n", This
, iface
, debugstr_guid(riid
), riid
, rgszNames
, cNames
, lcid
, rgDispId
);
3248 EnterCriticalSection(&This
->cs
);
3250 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3253 hr
= IBasicVideo_GetIDsOfNames(pBasicVideo
, riid
, rgszNames
, cNames
, lcid
, rgDispId
);
3255 LeaveCriticalSection(&This
->cs
);
3260 static HRESULT WINAPI
BasicVideo_Invoke(IBasicVideo2
*iface
, DISPID dispIdMember
, REFIID riid
,
3261 LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
, VARIANT
*pVarResult
, EXCEPINFO
*pExepInfo
,
3264 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3265 IBasicVideo
*pBasicVideo
;
3268 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
);
3270 EnterCriticalSection(&This
->cs
);
3272 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3275 hr
= IBasicVideo_Invoke(pBasicVideo
, dispIdMember
, riid
, lcid
, wFlags
, pDispParams
, pVarResult
, pExepInfo
, puArgErr
);
3277 LeaveCriticalSection(&This
->cs
);
3282 /*** IBasicVideo methods ***/
3283 static HRESULT WINAPI
BasicVideo_get_AvgTimePerFrame(IBasicVideo2
*iface
, REFTIME
*pAvgTimePerFrame
)
3285 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3286 IBasicVideo
*pBasicVideo
;
3289 TRACE("(%p/%p)->(%p)\n", This
, iface
, pAvgTimePerFrame
);
3291 EnterCriticalSection(&This
->cs
);
3293 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3296 hr
= IBasicVideo_get_AvgTimePerFrame(pBasicVideo
, pAvgTimePerFrame
);
3298 LeaveCriticalSection(&This
->cs
);
3303 static HRESULT WINAPI
BasicVideo_get_BitRate(IBasicVideo2
*iface
, LONG
*pBitRate
)
3305 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3306 IBasicVideo
*pBasicVideo
;
3309 TRACE("(%p/%p)->(%p)\n", This
, iface
, pBitRate
);
3311 EnterCriticalSection(&This
->cs
);
3313 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3316 hr
= IBasicVideo_get_BitRate(pBasicVideo
, pBitRate
);
3318 LeaveCriticalSection(&This
->cs
);
3323 static HRESULT WINAPI
BasicVideo_get_BitErrorRate(IBasicVideo2
*iface
, LONG
*pBitErrorRate
)
3325 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3326 IBasicVideo
*pBasicVideo
;
3329 TRACE("(%p/%p)->(%p)\n", This
, iface
, pBitErrorRate
);
3331 EnterCriticalSection(&This
->cs
);
3333 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3336 hr
= IBasicVideo_get_BitErrorRate(pBasicVideo
, pBitErrorRate
);
3338 LeaveCriticalSection(&This
->cs
);
3343 static HRESULT WINAPI
BasicVideo_get_VideoWidth(IBasicVideo2
*iface
, LONG
*pVideoWidth
)
3345 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3346 IBasicVideo
*pBasicVideo
;
3349 TRACE("(%p/%p)->(%p)\n", This
, iface
, pVideoWidth
);
3351 EnterCriticalSection(&This
->cs
);
3353 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3356 hr
= IBasicVideo_get_VideoWidth(pBasicVideo
, pVideoWidth
);
3358 LeaveCriticalSection(&This
->cs
);
3363 static HRESULT WINAPI
BasicVideo_get_VideoHeight(IBasicVideo2
*iface
, LONG
*pVideoHeight
)
3365 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3366 IBasicVideo
*pBasicVideo
;
3369 TRACE("(%p/%p)->(%p)\n", This
, iface
, pVideoHeight
);
3371 EnterCriticalSection(&This
->cs
);
3373 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3376 hr
= IBasicVideo_get_VideoHeight(pBasicVideo
, pVideoHeight
);
3378 LeaveCriticalSection(&This
->cs
);
3383 static HRESULT WINAPI
BasicVideo_put_SourceLeft(IBasicVideo2
*iface
, LONG SourceLeft
)
3385 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3386 IBasicVideo
*pBasicVideo
;
3389 TRACE("(%p/%p)->(%d)\n", This
, iface
, SourceLeft
);
3391 EnterCriticalSection(&This
->cs
);
3393 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3396 hr
= IBasicVideo_put_SourceLeft(pBasicVideo
, SourceLeft
);
3398 LeaveCriticalSection(&This
->cs
);
3403 static HRESULT WINAPI
BasicVideo_get_SourceLeft(IBasicVideo2
*iface
, LONG
*pSourceLeft
)
3405 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3406 IBasicVideo
*pBasicVideo
;
3409 TRACE("(%p/%p)->(%p)\n", This
, iface
, pSourceLeft
);
3411 EnterCriticalSection(&This
->cs
);
3413 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3416 hr
= IBasicVideo_get_SourceLeft(pBasicVideo
, pSourceLeft
);
3418 LeaveCriticalSection(&This
->cs
);
3423 static HRESULT WINAPI
BasicVideo_put_SourceWidth(IBasicVideo2
*iface
, LONG SourceWidth
)
3425 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3426 IBasicVideo
*pBasicVideo
;
3429 TRACE("(%p/%p)->(%d)\n", This
, iface
, SourceWidth
);
3431 EnterCriticalSection(&This
->cs
);
3433 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3436 hr
= IBasicVideo_put_SourceWidth(pBasicVideo
, SourceWidth
);
3438 LeaveCriticalSection(&This
->cs
);
3443 static HRESULT WINAPI
BasicVideo_get_SourceWidth(IBasicVideo2
*iface
, LONG
*pSourceWidth
)
3445 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3446 IBasicVideo
*pBasicVideo
;
3449 TRACE("(%p/%p)->(%p)\n", This
, iface
, pSourceWidth
);
3451 EnterCriticalSection(&This
->cs
);
3453 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3456 hr
= IBasicVideo_get_SourceWidth(pBasicVideo
, pSourceWidth
);
3458 LeaveCriticalSection(&This
->cs
);
3463 static HRESULT WINAPI
BasicVideo_put_SourceTop(IBasicVideo2
*iface
, LONG SourceTop
)
3465 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3466 IBasicVideo
*pBasicVideo
;
3469 TRACE("(%p/%p)->(%d)\n", This
, iface
, SourceTop
);
3471 EnterCriticalSection(&This
->cs
);
3473 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3476 hr
= IBasicVideo_put_SourceTop(pBasicVideo
, SourceTop
);
3478 LeaveCriticalSection(&This
->cs
);
3483 static HRESULT WINAPI
BasicVideo_get_SourceTop(IBasicVideo2
*iface
, LONG
*pSourceTop
)
3485 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3486 IBasicVideo
*pBasicVideo
;
3489 TRACE("(%p/%p)->(%p)\n", This
, iface
, pSourceTop
);
3491 EnterCriticalSection(&This
->cs
);
3493 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3496 hr
= IBasicVideo_get_SourceTop(pBasicVideo
, pSourceTop
);
3498 LeaveCriticalSection(&This
->cs
);
3503 static HRESULT WINAPI
BasicVideo_put_SourceHeight(IBasicVideo2
*iface
, LONG SourceHeight
)
3505 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3506 IBasicVideo
*pBasicVideo
;
3509 TRACE("(%p/%p)->(%d)\n", This
, iface
, SourceHeight
);
3511 EnterCriticalSection(&This
->cs
);
3513 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3516 hr
= IBasicVideo_put_SourceHeight(pBasicVideo
, SourceHeight
);
3518 LeaveCriticalSection(&This
->cs
);
3523 static HRESULT WINAPI
BasicVideo_get_SourceHeight(IBasicVideo2
*iface
, LONG
*pSourceHeight
)
3525 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3526 IBasicVideo
*pBasicVideo
;
3529 TRACE("(%p/%p)->(%p)\n", This
, iface
, pSourceHeight
);
3531 EnterCriticalSection(&This
->cs
);
3533 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3536 hr
= IBasicVideo_get_SourceHeight(pBasicVideo
, pSourceHeight
);
3538 LeaveCriticalSection(&This
->cs
);
3543 static HRESULT WINAPI
BasicVideo_put_DestinationLeft(IBasicVideo2
*iface
, LONG DestinationLeft
)
3545 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3546 IBasicVideo
*pBasicVideo
;
3549 TRACE("(%p/%p)->(%d)\n", This
, iface
, DestinationLeft
);
3551 EnterCriticalSection(&This
->cs
);
3553 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3556 hr
= IBasicVideo_put_DestinationLeft(pBasicVideo
, DestinationLeft
);
3558 LeaveCriticalSection(&This
->cs
);
3563 static HRESULT WINAPI
BasicVideo_get_DestinationLeft(IBasicVideo2
*iface
, LONG
*pDestinationLeft
)
3565 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3566 IBasicVideo
*pBasicVideo
;
3569 TRACE("(%p/%p)->(%p)\n", This
, iface
, pDestinationLeft
);
3571 EnterCriticalSection(&This
->cs
);
3573 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3576 hr
= IBasicVideo_get_DestinationLeft(pBasicVideo
, pDestinationLeft
);
3578 LeaveCriticalSection(&This
->cs
);
3583 static HRESULT WINAPI
BasicVideo_put_DestinationWidth(IBasicVideo2
*iface
, LONG DestinationWidth
)
3585 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3586 IBasicVideo
*pBasicVideo
;
3589 TRACE("(%p/%p)->(%d)\n", This
, iface
, DestinationWidth
);
3591 EnterCriticalSection(&This
->cs
);
3593 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3596 hr
= IBasicVideo_put_DestinationWidth(pBasicVideo
, DestinationWidth
);
3598 LeaveCriticalSection(&This
->cs
);
3603 static HRESULT WINAPI
BasicVideo_get_DestinationWidth(IBasicVideo2
*iface
, LONG
*pDestinationWidth
)
3605 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3606 IBasicVideo
*pBasicVideo
;
3609 TRACE("(%p/%p)->(%p)\n", This
, iface
, pDestinationWidth
);
3611 EnterCriticalSection(&This
->cs
);
3613 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3616 hr
= IBasicVideo_get_DestinationWidth(pBasicVideo
, pDestinationWidth
);
3618 LeaveCriticalSection(&This
->cs
);
3623 static HRESULT WINAPI
BasicVideo_put_DestinationTop(IBasicVideo2
*iface
, LONG DestinationTop
)
3625 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3626 IBasicVideo
*pBasicVideo
;
3629 TRACE("(%p/%p)->(%d)\n", This
, iface
, DestinationTop
);
3631 EnterCriticalSection(&This
->cs
);
3633 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3636 hr
= IBasicVideo_put_DestinationTop(pBasicVideo
, DestinationTop
);
3638 LeaveCriticalSection(&This
->cs
);
3643 static HRESULT WINAPI
BasicVideo_get_DestinationTop(IBasicVideo2
*iface
, LONG
*pDestinationTop
)
3645 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3646 IBasicVideo
*pBasicVideo
;
3649 TRACE("(%p/%p)->(%p)\n", This
, iface
, pDestinationTop
);
3651 EnterCriticalSection(&This
->cs
);
3653 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3656 hr
= IBasicVideo_get_DestinationTop(pBasicVideo
, pDestinationTop
);
3658 LeaveCriticalSection(&This
->cs
);
3663 static HRESULT WINAPI
BasicVideo_put_DestinationHeight(IBasicVideo2
*iface
, LONG DestinationHeight
)
3665 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3666 IBasicVideo
*pBasicVideo
;
3669 TRACE("(%p/%p)->(%d)\n", This
, iface
, DestinationHeight
);
3671 EnterCriticalSection(&This
->cs
);
3673 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3676 hr
= IBasicVideo_put_DestinationHeight(pBasicVideo
, DestinationHeight
);
3678 LeaveCriticalSection(&This
->cs
);
3683 static HRESULT WINAPI
BasicVideo_get_DestinationHeight(IBasicVideo2
*iface
,
3684 LONG
*pDestinationHeight
)
3686 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3687 IBasicVideo
*pBasicVideo
;
3690 TRACE("(%p/%p)->(%p)\n", This
, iface
, pDestinationHeight
);
3692 EnterCriticalSection(&This
->cs
);
3694 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3697 hr
= IBasicVideo_get_DestinationHeight(pBasicVideo
, pDestinationHeight
);
3699 LeaveCriticalSection(&This
->cs
);
3704 static HRESULT WINAPI
BasicVideo_SetSourcePosition(IBasicVideo2
*iface
, LONG Left
, LONG Top
,
3705 LONG Width
, LONG Height
)
3707 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3708 IBasicVideo
*pBasicVideo
;
3711 TRACE("(%p/%p)->(%d, %d, %d, %d)\n", This
, iface
, Left
, Top
, Width
, Height
);
3713 EnterCriticalSection(&This
->cs
);
3715 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3718 hr
= IBasicVideo_SetSourcePosition(pBasicVideo
, Left
, Top
, Width
, Height
);
3720 LeaveCriticalSection(&This
->cs
);
3725 static HRESULT WINAPI
BasicVideo_GetSourcePosition(IBasicVideo2
*iface
, LONG
*pLeft
, LONG
*pTop
,
3726 LONG
*pWidth
, LONG
*pHeight
)
3728 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3729 IBasicVideo
*pBasicVideo
;
3732 TRACE("(%p/%p)->(%p, %p, %p, %p)\n", This
, iface
, pLeft
, pTop
, pWidth
, pHeight
);
3734 EnterCriticalSection(&This
->cs
);
3736 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3739 hr
= IBasicVideo_GetSourcePosition(pBasicVideo
, pLeft
, pTop
, pWidth
, pHeight
);
3741 LeaveCriticalSection(&This
->cs
);
3746 static HRESULT WINAPI
BasicVideo_SetDefaultSourcePosition(IBasicVideo2
*iface
)
3748 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3749 IBasicVideo
*pBasicVideo
;
3752 TRACE("(%p/%p)->()\n", This
, iface
);
3754 EnterCriticalSection(&This
->cs
);
3756 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3759 hr
= IBasicVideo_SetDefaultSourcePosition(pBasicVideo
);
3761 LeaveCriticalSection(&This
->cs
);
3766 static HRESULT WINAPI
BasicVideo_SetDestinationPosition(IBasicVideo2
*iface
, LONG Left
, LONG Top
,
3767 LONG Width
, LONG Height
)
3769 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3770 IBasicVideo
*pBasicVideo
;
3773 TRACE("(%p/%p)->(%d, %d, %d, %d)\n", This
, iface
, Left
, Top
, Width
, Height
);
3775 EnterCriticalSection(&This
->cs
);
3777 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3780 hr
= IBasicVideo_SetDestinationPosition(pBasicVideo
, Left
, Top
, Width
, Height
);
3782 LeaveCriticalSection(&This
->cs
);
3787 static HRESULT WINAPI
BasicVideo_GetDestinationPosition(IBasicVideo2
*iface
, LONG
*pLeft
,
3788 LONG
*pTop
, LONG
*pWidth
, LONG
*pHeight
)
3790 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3791 IBasicVideo
*pBasicVideo
;
3794 TRACE("(%p/%p)->(%p, %p, %p, %p)\n", This
, iface
, pLeft
, pTop
, pWidth
, pHeight
);
3796 EnterCriticalSection(&This
->cs
);
3798 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3801 hr
= IBasicVideo_GetDestinationPosition(pBasicVideo
, pLeft
, pTop
, pWidth
, pHeight
);
3803 LeaveCriticalSection(&This
->cs
);
3808 static HRESULT WINAPI
BasicVideo_SetDefaultDestinationPosition(IBasicVideo2
*iface
)
3810 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3811 IBasicVideo
*pBasicVideo
;
3814 TRACE("(%p/%p)->()\n", This
, iface
);
3816 EnterCriticalSection(&This
->cs
);
3818 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3821 hr
= IBasicVideo_SetDefaultDestinationPosition(pBasicVideo
);
3823 LeaveCriticalSection(&This
->cs
);
3828 static HRESULT WINAPI
BasicVideo_GetVideoSize(IBasicVideo2
*iface
, LONG
*pWidth
, LONG
*pHeight
)
3830 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3831 IBasicVideo
*pBasicVideo
;
3834 TRACE("(%p/%p)->(%p, %p)\n", This
, iface
, pWidth
, pHeight
);
3836 EnterCriticalSection(&This
->cs
);
3838 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3841 hr
= IBasicVideo_GetVideoSize(pBasicVideo
, pWidth
, pHeight
);
3843 LeaveCriticalSection(&This
->cs
);
3848 static HRESULT WINAPI
BasicVideo_GetVideoPaletteEntries(IBasicVideo2
*iface
, LONG StartIndex
,
3849 LONG Entries
, LONG
*pRetrieved
, LONG
*pPalette
)
3851 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3852 IBasicVideo
*pBasicVideo
;
3855 TRACE("(%p/%p)->(%d, %d, %p, %p)\n", This
, iface
, StartIndex
, Entries
, pRetrieved
, pPalette
);
3857 EnterCriticalSection(&This
->cs
);
3859 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3862 hr
= IBasicVideo_GetVideoPaletteEntries(pBasicVideo
, StartIndex
, Entries
, pRetrieved
, pPalette
);
3864 LeaveCriticalSection(&This
->cs
);
3869 static HRESULT WINAPI
BasicVideo_GetCurrentImage(IBasicVideo2
*iface
, LONG
*pBufferSize
,
3872 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3873 IBasicVideo
*pBasicVideo
;
3876 TRACE("(%p/%p)->(%p, %p)\n", This
, iface
, pBufferSize
, pDIBImage
);
3878 EnterCriticalSection(&This
->cs
);
3880 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3883 hr
= IBasicVideo_GetCurrentImage(pBasicVideo
, pBufferSize
, pDIBImage
);
3885 LeaveCriticalSection(&This
->cs
);
3890 static HRESULT WINAPI
BasicVideo_IsUsingDefaultSource(IBasicVideo2
*iface
)
3892 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3893 IBasicVideo
*pBasicVideo
;
3896 TRACE("(%p/%p)->()\n", This
, iface
);
3898 EnterCriticalSection(&This
->cs
);
3900 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3903 hr
= IBasicVideo_IsUsingDefaultSource(pBasicVideo
);
3905 LeaveCriticalSection(&This
->cs
);
3910 static HRESULT WINAPI
BasicVideo_IsUsingDefaultDestination(IBasicVideo2
*iface
)
3912 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3913 IBasicVideo
*pBasicVideo
;
3916 TRACE("(%p/%p)->()\n", This
, iface
);
3918 EnterCriticalSection(&This
->cs
);
3920 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3923 hr
= IBasicVideo_IsUsingDefaultDestination(pBasicVideo
);
3925 LeaveCriticalSection(&This
->cs
);
3930 static HRESULT WINAPI
BasicVideo2_GetPreferredAspectRatio(IBasicVideo2
*iface
, LONG
*plAspectX
,
3933 IFilterGraphImpl
*This
= impl_from_IBasicVideo2(iface
);
3934 IBasicVideo2
*pBasicVideo2
;
3937 TRACE("(%p/%p)->()\n", This
, iface
);
3939 EnterCriticalSection(&This
->cs
);
3941 hr
= GetTargetInterface(This
, &IID_IBasicVideo2
, (LPVOID
*)&pBasicVideo2
);
3944 hr
= BasicVideo2_GetPreferredAspectRatio(iface
, plAspectX
, plAspectY
);
3946 LeaveCriticalSection(&This
->cs
);
3951 static const IBasicVideo2Vtbl IBasicVideo_VTable
=
3953 BasicVideo_QueryInterface
,
3956 BasicVideo_GetTypeInfoCount
,
3957 BasicVideo_GetTypeInfo
,
3958 BasicVideo_GetIDsOfNames
,
3960 BasicVideo_get_AvgTimePerFrame
,
3961 BasicVideo_get_BitRate
,
3962 BasicVideo_get_BitErrorRate
,
3963 BasicVideo_get_VideoWidth
,
3964 BasicVideo_get_VideoHeight
,
3965 BasicVideo_put_SourceLeft
,
3966 BasicVideo_get_SourceLeft
,
3967 BasicVideo_put_SourceWidth
,
3968 BasicVideo_get_SourceWidth
,
3969 BasicVideo_put_SourceTop
,
3970 BasicVideo_get_SourceTop
,
3971 BasicVideo_put_SourceHeight
,
3972 BasicVideo_get_SourceHeight
,
3973 BasicVideo_put_DestinationLeft
,
3974 BasicVideo_get_DestinationLeft
,
3975 BasicVideo_put_DestinationWidth
,
3976 BasicVideo_get_DestinationWidth
,
3977 BasicVideo_put_DestinationTop
,
3978 BasicVideo_get_DestinationTop
,
3979 BasicVideo_put_DestinationHeight
,
3980 BasicVideo_get_DestinationHeight
,
3981 BasicVideo_SetSourcePosition
,
3982 BasicVideo_GetSourcePosition
,
3983 BasicVideo_SetDefaultSourcePosition
,
3984 BasicVideo_SetDestinationPosition
,
3985 BasicVideo_GetDestinationPosition
,
3986 BasicVideo_SetDefaultDestinationPosition
,
3987 BasicVideo_GetVideoSize
,
3988 BasicVideo_GetVideoPaletteEntries
,
3989 BasicVideo_GetCurrentImage
,
3990 BasicVideo_IsUsingDefaultSource
,
3991 BasicVideo_IsUsingDefaultDestination
,
3992 BasicVideo2_GetPreferredAspectRatio
3995 static inline IFilterGraphImpl
*impl_from_IVideoWindow(IVideoWindow
*iface
)
3997 return CONTAINING_RECORD(iface
, IFilterGraphImpl
, IVideoWindow_iface
);
4000 static HRESULT WINAPI
VideoWindow_QueryInterface(IVideoWindow
*iface
, REFIID riid
, void **ppvObj
)
4002 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4004 TRACE("(%p/%p)->(%s (%p), %p)\n", This
, iface
, debugstr_guid(riid
), riid
, ppvObj
);
4006 return IUnknown_QueryInterface(This
->outer_unk
, riid
, ppvObj
);
4009 static ULONG WINAPI
VideoWindow_AddRef(IVideoWindow
*iface
)
4011 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4013 TRACE("(%p/%p)->()\n", This
, iface
);
4015 return IUnknown_AddRef(This
->outer_unk
);
4018 static ULONG WINAPI
VideoWindow_Release(IVideoWindow
*iface
)
4020 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4022 TRACE("(%p/%p)->()\n", This
, iface
);
4024 return IUnknown_Release(This
->outer_unk
);
4027 /*** IDispatch methods ***/
4028 static HRESULT WINAPI
VideoWindow_GetTypeInfoCount(IVideoWindow
*iface
, UINT
*pctinfo
)
4030 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4031 IVideoWindow
*pVideoWindow
;
4034 TRACE("(%p/%p)->(%p)\n", This
, iface
, pctinfo
);
4036 EnterCriticalSection(&This
->cs
);
4038 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4041 hr
= IVideoWindow_GetTypeInfoCount(pVideoWindow
, pctinfo
);
4043 LeaveCriticalSection(&This
->cs
);
4048 static HRESULT WINAPI
VideoWindow_GetTypeInfo(IVideoWindow
*iface
, UINT iTInfo
, LCID lcid
,
4049 ITypeInfo
**ppTInfo
)
4051 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4052 IVideoWindow
*pVideoWindow
;
4055 TRACE("(%p/%p)->(%d, %d, %p)\n", This
, iface
, iTInfo
, lcid
, ppTInfo
);
4057 EnterCriticalSection(&This
->cs
);
4059 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4062 hr
= IVideoWindow_GetTypeInfo(pVideoWindow
, iTInfo
, lcid
, ppTInfo
);
4064 LeaveCriticalSection(&This
->cs
);
4069 static HRESULT WINAPI
VideoWindow_GetIDsOfNames(IVideoWindow
*iface
, REFIID riid
,
4070 LPOLESTR
*rgszNames
, UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
4072 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4073 IVideoWindow
*pVideoWindow
;
4076 TRACE("(%p/%p)->(%s (%p), %p, %d, %d, %p)\n", This
, iface
, debugstr_guid(riid
), riid
, rgszNames
, cNames
, lcid
, rgDispId
);
4078 EnterCriticalSection(&This
->cs
);
4080 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4083 hr
= IVideoWindow_GetIDsOfNames(pVideoWindow
, riid
, rgszNames
, cNames
, lcid
, rgDispId
);
4085 LeaveCriticalSection(&This
->cs
);
4090 static HRESULT WINAPI
VideoWindow_Invoke(IVideoWindow
*iface
, DISPID dispIdMember
, REFIID riid
,
4091 LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
, VARIANT
*pVarResult
, EXCEPINFO
*pExepInfo
,
4094 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4095 IVideoWindow
*pVideoWindow
;
4098 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
);
4100 EnterCriticalSection(&This
->cs
);
4102 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4105 hr
= IVideoWindow_Invoke(pVideoWindow
, dispIdMember
, riid
, lcid
, wFlags
, pDispParams
, pVarResult
, pExepInfo
, puArgErr
);
4107 LeaveCriticalSection(&This
->cs
);
4113 /*** IVideoWindow methods ***/
4114 static HRESULT WINAPI
VideoWindow_put_Caption(IVideoWindow
*iface
, BSTR strCaption
)
4116 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4117 IVideoWindow
*pVideoWindow
;
4120 TRACE("(%p/%p)->(%s (%p))\n", This
, iface
, debugstr_w(strCaption
), strCaption
);
4122 EnterCriticalSection(&This
->cs
);
4124 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4127 hr
= IVideoWindow_put_Caption(pVideoWindow
, strCaption
);
4129 LeaveCriticalSection(&This
->cs
);
4134 static HRESULT WINAPI
VideoWindow_get_Caption(IVideoWindow
*iface
, BSTR
*strCaption
)
4136 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4137 IVideoWindow
*pVideoWindow
;
4140 TRACE("(%p/%p)->(%p)\n", This
, iface
, strCaption
);
4142 EnterCriticalSection(&This
->cs
);
4144 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4147 hr
= IVideoWindow_get_Caption(pVideoWindow
, strCaption
);
4149 LeaveCriticalSection(&This
->cs
);
4154 static HRESULT WINAPI
VideoWindow_put_WindowStyle(IVideoWindow
*iface
, LONG WindowStyle
)
4156 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4157 IVideoWindow
*pVideoWindow
;
4160 TRACE("(%p/%p)->(%d)\n", This
, iface
, WindowStyle
);
4162 EnterCriticalSection(&This
->cs
);
4164 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4167 hr
= IVideoWindow_put_WindowStyle(pVideoWindow
, WindowStyle
);
4169 LeaveCriticalSection(&This
->cs
);
4174 static HRESULT WINAPI
VideoWindow_get_WindowStyle(IVideoWindow
*iface
, LONG
*WindowStyle
)
4176 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4177 IVideoWindow
*pVideoWindow
;
4180 TRACE("(%p/%p)->(%p)\n", This
, iface
, WindowStyle
);
4182 EnterCriticalSection(&This
->cs
);
4184 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4187 hr
= IVideoWindow_get_WindowStyle(pVideoWindow
, WindowStyle
);
4189 LeaveCriticalSection(&This
->cs
);
4194 static HRESULT WINAPI
VideoWindow_put_WindowStyleEx(IVideoWindow
*iface
, LONG WindowStyleEx
)
4196 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4197 IVideoWindow
*pVideoWindow
;
4200 TRACE("(%p/%p)->(%d)\n", This
, iface
, WindowStyleEx
);
4202 EnterCriticalSection(&This
->cs
);
4204 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4207 hr
= IVideoWindow_put_WindowStyleEx(pVideoWindow
, WindowStyleEx
);
4209 LeaveCriticalSection(&This
->cs
);
4214 static HRESULT WINAPI
VideoWindow_get_WindowStyleEx(IVideoWindow
*iface
, LONG
*WindowStyleEx
)
4216 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4217 IVideoWindow
*pVideoWindow
;
4220 TRACE("(%p/%p)->(%p)\n", This
, iface
, WindowStyleEx
);
4222 EnterCriticalSection(&This
->cs
);
4224 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4227 hr
= IVideoWindow_get_WindowStyleEx(pVideoWindow
, WindowStyleEx
);
4229 LeaveCriticalSection(&This
->cs
);
4234 static HRESULT WINAPI
VideoWindow_put_AutoShow(IVideoWindow
*iface
, LONG AutoShow
)
4236 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4237 IVideoWindow
*pVideoWindow
;
4240 TRACE("(%p/%p)->(%d)\n", This
, iface
, AutoShow
);
4242 EnterCriticalSection(&This
->cs
);
4244 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4247 hr
= IVideoWindow_put_AutoShow(pVideoWindow
, AutoShow
);
4249 LeaveCriticalSection(&This
->cs
);
4254 static HRESULT WINAPI
VideoWindow_get_AutoShow(IVideoWindow
*iface
, LONG
*AutoShow
)
4256 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4257 IVideoWindow
*pVideoWindow
;
4260 TRACE("(%p/%p)->(%p)\n", This
, iface
, AutoShow
);
4262 EnterCriticalSection(&This
->cs
);
4264 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4267 hr
= IVideoWindow_get_AutoShow(pVideoWindow
, AutoShow
);
4269 LeaveCriticalSection(&This
->cs
);
4274 static HRESULT WINAPI
VideoWindow_put_WindowState(IVideoWindow
*iface
, LONG WindowState
)
4276 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4277 IVideoWindow
*pVideoWindow
;
4280 TRACE("(%p/%p)->(%d)\n", This
, iface
, WindowState
);
4282 EnterCriticalSection(&This
->cs
);
4284 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4287 hr
= IVideoWindow_put_WindowState(pVideoWindow
, WindowState
);
4289 LeaveCriticalSection(&This
->cs
);
4294 static HRESULT WINAPI
VideoWindow_get_WindowState(IVideoWindow
*iface
, LONG
*WindowState
)
4296 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4297 IVideoWindow
*pVideoWindow
;
4300 TRACE("(%p/%p)->(%p)\n", This
, iface
, WindowState
);
4302 EnterCriticalSection(&This
->cs
);
4304 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4307 hr
= IVideoWindow_get_WindowState(pVideoWindow
, WindowState
);
4309 LeaveCriticalSection(&This
->cs
);
4314 static HRESULT WINAPI
VideoWindow_put_BackgroundPalette(IVideoWindow
*iface
, LONG BackgroundPalette
)
4316 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4317 IVideoWindow
*pVideoWindow
;
4320 TRACE("(%p/%p)->(%d)\n", This
, iface
, BackgroundPalette
);
4322 EnterCriticalSection(&This
->cs
);
4324 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4327 hr
= IVideoWindow_put_BackgroundPalette(pVideoWindow
, BackgroundPalette
);
4329 LeaveCriticalSection(&This
->cs
);
4334 static HRESULT WINAPI
VideoWindow_get_BackgroundPalette(IVideoWindow
*iface
,
4335 LONG
*pBackgroundPalette
)
4337 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4338 IVideoWindow
*pVideoWindow
;
4341 TRACE("(%p/%p)->(%p)\n", This
, iface
, pBackgroundPalette
);
4343 EnterCriticalSection(&This
->cs
);
4345 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4348 hr
= IVideoWindow_get_BackgroundPalette(pVideoWindow
, pBackgroundPalette
);
4350 LeaveCriticalSection(&This
->cs
);
4355 static HRESULT WINAPI
VideoWindow_put_Visible(IVideoWindow
*iface
, LONG Visible
)
4357 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4358 IVideoWindow
*pVideoWindow
;
4361 TRACE("(%p/%p)->(%d)\n", This
, iface
, Visible
);
4363 EnterCriticalSection(&This
->cs
);
4365 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4368 hr
= IVideoWindow_put_Visible(pVideoWindow
, Visible
);
4370 LeaveCriticalSection(&This
->cs
);
4375 static HRESULT WINAPI
VideoWindow_get_Visible(IVideoWindow
*iface
, LONG
*pVisible
)
4377 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4378 IVideoWindow
*pVideoWindow
;
4381 TRACE("(%p/%p)->(%p)\n", This
, iface
, pVisible
);
4383 EnterCriticalSection(&This
->cs
);
4385 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4388 hr
= IVideoWindow_get_Visible(pVideoWindow
, pVisible
);
4390 LeaveCriticalSection(&This
->cs
);
4395 static HRESULT WINAPI
VideoWindow_put_Left(IVideoWindow
*iface
, LONG Left
)
4397 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4398 IVideoWindow
*pVideoWindow
;
4401 TRACE("(%p/%p)->(%d)\n", This
, iface
, Left
);
4403 EnterCriticalSection(&This
->cs
);
4405 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4408 hr
= IVideoWindow_put_Left(pVideoWindow
, Left
);
4410 LeaveCriticalSection(&This
->cs
);
4415 static HRESULT WINAPI
VideoWindow_get_Left(IVideoWindow
*iface
, LONG
*pLeft
)
4417 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4418 IVideoWindow
*pVideoWindow
;
4421 TRACE("(%p/%p)->(%p)\n", This
, iface
, pLeft
);
4423 EnterCriticalSection(&This
->cs
);
4425 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4428 hr
= IVideoWindow_get_Left(pVideoWindow
, pLeft
);
4430 LeaveCriticalSection(&This
->cs
);
4435 static HRESULT WINAPI
VideoWindow_put_Width(IVideoWindow
*iface
, LONG Width
)
4437 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4438 IVideoWindow
*pVideoWindow
;
4441 TRACE("(%p/%p)->(%d)\n", This
, iface
, Width
);
4443 EnterCriticalSection(&This
->cs
);
4445 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4448 hr
= IVideoWindow_put_Width(pVideoWindow
, Width
);
4450 LeaveCriticalSection(&This
->cs
);
4455 static HRESULT WINAPI
VideoWindow_get_Width(IVideoWindow
*iface
, LONG
*pWidth
)
4457 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4458 IVideoWindow
*pVideoWindow
;
4461 TRACE("(%p/%p)->(%p)\n", This
, iface
, pWidth
);
4463 EnterCriticalSection(&This
->cs
);
4465 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4468 hr
= IVideoWindow_get_Width(pVideoWindow
, pWidth
);
4470 LeaveCriticalSection(&This
->cs
);
4475 static HRESULT WINAPI
VideoWindow_put_Top(IVideoWindow
*iface
, LONG Top
)
4477 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4478 IVideoWindow
*pVideoWindow
;
4481 TRACE("(%p/%p)->(%d)\n", This
, iface
, Top
);
4483 EnterCriticalSection(&This
->cs
);
4485 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4488 hr
= IVideoWindow_put_Top(pVideoWindow
, Top
);
4490 LeaveCriticalSection(&This
->cs
);
4495 static HRESULT WINAPI
VideoWindow_get_Top(IVideoWindow
*iface
, LONG
*pTop
)
4497 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4498 IVideoWindow
*pVideoWindow
;
4501 TRACE("(%p/%p)->(%p)\n", This
, iface
, pTop
);
4503 EnterCriticalSection(&This
->cs
);
4505 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4508 hr
= IVideoWindow_get_Top(pVideoWindow
, pTop
);
4510 LeaveCriticalSection(&This
->cs
);
4515 static HRESULT WINAPI
VideoWindow_put_Height(IVideoWindow
*iface
, LONG Height
)
4517 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4518 IVideoWindow
*pVideoWindow
;
4521 TRACE("(%p/%p)->(%d)\n", This
, iface
, Height
);
4523 EnterCriticalSection(&This
->cs
);
4525 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4528 hr
= IVideoWindow_put_Height(pVideoWindow
, Height
);
4530 LeaveCriticalSection(&This
->cs
);
4535 static HRESULT WINAPI
VideoWindow_get_Height(IVideoWindow
*iface
, LONG
*pHeight
)
4537 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4538 IVideoWindow
*pVideoWindow
;
4541 TRACE("(%p/%p)->(%p)\n", This
, iface
, pHeight
);
4543 EnterCriticalSection(&This
->cs
);
4545 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4548 hr
= IVideoWindow_get_Height(pVideoWindow
, pHeight
);
4550 LeaveCriticalSection(&This
->cs
);
4555 static HRESULT WINAPI
VideoWindow_put_Owner(IVideoWindow
*iface
, OAHWND Owner
)
4557 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4558 IVideoWindow
*pVideoWindow
;
4561 TRACE("(%p/%p)->(%08x)\n", This
, iface
, (DWORD
) Owner
);
4563 EnterCriticalSection(&This
->cs
);
4565 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4568 hr
= IVideoWindow_put_Owner(pVideoWindow
, Owner
);
4570 LeaveCriticalSection(&This
->cs
);
4575 static HRESULT WINAPI
VideoWindow_get_Owner(IVideoWindow
*iface
, OAHWND
*Owner
)
4577 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4578 IVideoWindow
*pVideoWindow
;
4581 TRACE("(%p/%p)->(%p)\n", This
, iface
, Owner
);
4583 EnterCriticalSection(&This
->cs
);
4585 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4588 hr
= IVideoWindow_get_Owner(pVideoWindow
, Owner
);
4590 LeaveCriticalSection(&This
->cs
);
4595 static HRESULT WINAPI
VideoWindow_put_MessageDrain(IVideoWindow
*iface
, OAHWND Drain
)
4597 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4598 IVideoWindow
*pVideoWindow
;
4601 TRACE("(%p/%p)->(%08x)\n", This
, iface
, (DWORD
) Drain
);
4603 EnterCriticalSection(&This
->cs
);
4605 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4608 hr
= IVideoWindow_put_MessageDrain(pVideoWindow
, Drain
);
4610 LeaveCriticalSection(&This
->cs
);
4615 static HRESULT WINAPI
VideoWindow_get_MessageDrain(IVideoWindow
*iface
, OAHWND
*Drain
)
4617 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4618 IVideoWindow
*pVideoWindow
;
4621 TRACE("(%p/%p)->(%p)\n", This
, iface
, Drain
);
4623 EnterCriticalSection(&This
->cs
);
4625 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4628 hr
= IVideoWindow_get_MessageDrain(pVideoWindow
, Drain
);
4630 LeaveCriticalSection(&This
->cs
);
4635 static HRESULT WINAPI
VideoWindow_get_BorderColor(IVideoWindow
*iface
, LONG
*Color
)
4637 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4638 IVideoWindow
*pVideoWindow
;
4641 TRACE("(%p/%p)->(%p)\n", This
, iface
, Color
);
4643 EnterCriticalSection(&This
->cs
);
4645 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4648 hr
= IVideoWindow_get_BorderColor(pVideoWindow
, Color
);
4650 LeaveCriticalSection(&This
->cs
);
4655 static HRESULT WINAPI
VideoWindow_put_BorderColor(IVideoWindow
*iface
, LONG Color
)
4657 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4658 IVideoWindow
*pVideoWindow
;
4661 TRACE("(%p/%p)->(%d)\n", This
, iface
, Color
);
4663 EnterCriticalSection(&This
->cs
);
4665 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4668 hr
= IVideoWindow_put_BorderColor(pVideoWindow
, Color
);
4670 LeaveCriticalSection(&This
->cs
);
4675 static HRESULT WINAPI
VideoWindow_get_FullScreenMode(IVideoWindow
*iface
, LONG
*FullScreenMode
)
4677 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4678 IVideoWindow
*pVideoWindow
;
4681 TRACE("(%p/%p)->(%p)\n", This
, iface
, FullScreenMode
);
4683 EnterCriticalSection(&This
->cs
);
4685 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4688 hr
= IVideoWindow_get_FullScreenMode(pVideoWindow
, FullScreenMode
);
4690 LeaveCriticalSection(&This
->cs
);
4695 static HRESULT WINAPI
VideoWindow_put_FullScreenMode(IVideoWindow
*iface
, LONG FullScreenMode
)
4697 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4698 IVideoWindow
*pVideoWindow
;
4701 TRACE("(%p/%p)->(%d)\n", This
, iface
, FullScreenMode
);
4703 EnterCriticalSection(&This
->cs
);
4705 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4708 hr
= IVideoWindow_put_FullScreenMode(pVideoWindow
, FullScreenMode
);
4710 LeaveCriticalSection(&This
->cs
);
4715 static HRESULT WINAPI
VideoWindow_SetWindowForeground(IVideoWindow
*iface
, LONG Focus
)
4717 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4718 IVideoWindow
*pVideoWindow
;
4721 TRACE("(%p/%p)->(%d)\n", This
, iface
, Focus
);
4723 EnterCriticalSection(&This
->cs
);
4725 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4728 hr
= IVideoWindow_SetWindowForeground(pVideoWindow
, Focus
);
4730 LeaveCriticalSection(&This
->cs
);
4735 static HRESULT WINAPI
VideoWindow_NotifyOwnerMessage(IVideoWindow
*iface
, OAHWND hwnd
, LONG uMsg
,
4736 LONG_PTR wParam
, LONG_PTR lParam
)
4738 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4739 IVideoWindow
*pVideoWindow
;
4742 TRACE("(%p/%p)->(%08lx, %d, %08lx, %08lx)\n", This
, iface
, hwnd
, uMsg
, wParam
, lParam
);
4744 EnterCriticalSection(&This
->cs
);
4746 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4749 hr
= IVideoWindow_NotifyOwnerMessage(pVideoWindow
, hwnd
, uMsg
, wParam
, lParam
);
4751 LeaveCriticalSection(&This
->cs
);
4756 static HRESULT WINAPI
VideoWindow_SetWindowPosition(IVideoWindow
*iface
, LONG Left
, LONG Top
,
4757 LONG Width
, LONG Height
)
4759 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4760 IVideoWindow
*pVideoWindow
;
4763 TRACE("(%p/%p)->(%d, %d, %d, %d)\n", This
, iface
, Left
, Top
, Width
, Height
);
4765 EnterCriticalSection(&This
->cs
);
4767 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4770 hr
= IVideoWindow_SetWindowPosition(pVideoWindow
, Left
, Top
, Width
, Height
);
4772 LeaveCriticalSection(&This
->cs
);
4777 static HRESULT WINAPI
VideoWindow_GetWindowPosition(IVideoWindow
*iface
, LONG
*pLeft
, LONG
*pTop
,
4778 LONG
*pWidth
, LONG
*pHeight
)
4780 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4781 IVideoWindow
*pVideoWindow
;
4784 TRACE("(%p/%p)->(%p, %p, %p, %p)\n", This
, iface
, pLeft
, pTop
, pWidth
, pHeight
);
4786 EnterCriticalSection(&This
->cs
);
4788 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4791 hr
= IVideoWindow_GetWindowPosition(pVideoWindow
, pLeft
, pTop
, pWidth
, pHeight
);
4793 LeaveCriticalSection(&This
->cs
);
4798 static HRESULT WINAPI
VideoWindow_GetMinIdealImageSize(IVideoWindow
*iface
, LONG
*pWidth
,
4801 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4802 IVideoWindow
*pVideoWindow
;
4805 TRACE("(%p/%p)->(%p, %p)\n", This
, iface
, pWidth
, pHeight
);
4807 EnterCriticalSection(&This
->cs
);
4809 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4812 hr
= IVideoWindow_GetMinIdealImageSize(pVideoWindow
, pWidth
, pHeight
);
4814 LeaveCriticalSection(&This
->cs
);
4819 static HRESULT WINAPI
VideoWindow_GetMaxIdealImageSize(IVideoWindow
*iface
, LONG
*pWidth
,
4822 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4823 IVideoWindow
*pVideoWindow
;
4826 TRACE("(%p/%p)->(%p, %p)\n", This
, iface
, pWidth
, pHeight
);
4828 EnterCriticalSection(&This
->cs
);
4830 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4833 hr
= IVideoWindow_GetMaxIdealImageSize(pVideoWindow
, pWidth
, pHeight
);
4835 LeaveCriticalSection(&This
->cs
);
4840 static HRESULT WINAPI
VideoWindow_GetRestorePosition(IVideoWindow
*iface
, LONG
*pLeft
, LONG
*pTop
,
4841 LONG
*pWidth
, LONG
*pHeight
)
4843 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4844 IVideoWindow
*pVideoWindow
;
4847 TRACE("(%p/%p)->(%p, %p, %p, %p)\n", This
, iface
, pLeft
, pTop
, pWidth
, pHeight
);
4849 EnterCriticalSection(&This
->cs
);
4851 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4854 hr
= IVideoWindow_GetRestorePosition(pVideoWindow
, pLeft
, pTop
, pWidth
, pHeight
);
4856 LeaveCriticalSection(&This
->cs
);
4861 static HRESULT WINAPI
VideoWindow_HideCursor(IVideoWindow
*iface
, LONG HideCursor
)
4863 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4864 IVideoWindow
*pVideoWindow
;
4867 TRACE("(%p/%p)->(%d)\n", This
, iface
, HideCursor
);
4869 EnterCriticalSection(&This
->cs
);
4871 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4874 hr
= IVideoWindow_HideCursor(pVideoWindow
, HideCursor
);
4876 LeaveCriticalSection(&This
->cs
);
4881 static HRESULT WINAPI
VideoWindow_IsCursorHidden(IVideoWindow
*iface
, LONG
*CursorHidden
)
4883 IFilterGraphImpl
*This
= impl_from_IVideoWindow(iface
);
4884 IVideoWindow
*pVideoWindow
;
4887 TRACE("(%p/%p)->(%p)\n", This
, iface
, CursorHidden
);
4889 EnterCriticalSection(&This
->cs
);
4891 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4894 hr
= IVideoWindow_IsCursorHidden(pVideoWindow
, CursorHidden
);
4896 LeaveCriticalSection(&This
->cs
);
4902 static const IVideoWindowVtbl IVideoWindow_VTable
=
4904 VideoWindow_QueryInterface
,
4906 VideoWindow_Release
,
4907 VideoWindow_GetTypeInfoCount
,
4908 VideoWindow_GetTypeInfo
,
4909 VideoWindow_GetIDsOfNames
,
4911 VideoWindow_put_Caption
,
4912 VideoWindow_get_Caption
,
4913 VideoWindow_put_WindowStyle
,
4914 VideoWindow_get_WindowStyle
,
4915 VideoWindow_put_WindowStyleEx
,
4916 VideoWindow_get_WindowStyleEx
,
4917 VideoWindow_put_AutoShow
,
4918 VideoWindow_get_AutoShow
,
4919 VideoWindow_put_WindowState
,
4920 VideoWindow_get_WindowState
,
4921 VideoWindow_put_BackgroundPalette
,
4922 VideoWindow_get_BackgroundPalette
,
4923 VideoWindow_put_Visible
,
4924 VideoWindow_get_Visible
,
4925 VideoWindow_put_Left
,
4926 VideoWindow_get_Left
,
4927 VideoWindow_put_Width
,
4928 VideoWindow_get_Width
,
4929 VideoWindow_put_Top
,
4930 VideoWindow_get_Top
,
4931 VideoWindow_put_Height
,
4932 VideoWindow_get_Height
,
4933 VideoWindow_put_Owner
,
4934 VideoWindow_get_Owner
,
4935 VideoWindow_put_MessageDrain
,
4936 VideoWindow_get_MessageDrain
,
4937 VideoWindow_get_BorderColor
,
4938 VideoWindow_put_BorderColor
,
4939 VideoWindow_get_FullScreenMode
,
4940 VideoWindow_put_FullScreenMode
,
4941 VideoWindow_SetWindowForeground
,
4942 VideoWindow_NotifyOwnerMessage
,
4943 VideoWindow_SetWindowPosition
,
4944 VideoWindow_GetWindowPosition
,
4945 VideoWindow_GetMinIdealImageSize
,
4946 VideoWindow_GetMaxIdealImageSize
,
4947 VideoWindow_GetRestorePosition
,
4948 VideoWindow_HideCursor
,
4949 VideoWindow_IsCursorHidden
4952 static inline IFilterGraphImpl
*impl_from_IMediaEventEx(IMediaEventEx
*iface
)
4954 return CONTAINING_RECORD(iface
, IFilterGraphImpl
, IMediaEventEx_iface
);
4957 static HRESULT WINAPI
MediaEvent_QueryInterface(IMediaEventEx
*iface
, REFIID riid
, void **ppvObj
)
4959 IFilterGraphImpl
*This
= impl_from_IMediaEventEx(iface
);
4961 TRACE("(%p/%p)->(%s (%p), %p)\n", This
, iface
, debugstr_guid(riid
), riid
, ppvObj
);
4963 return IUnknown_QueryInterface(This
->outer_unk
, riid
, ppvObj
);
4966 static ULONG WINAPI
MediaEvent_AddRef(IMediaEventEx
*iface
)
4968 IFilterGraphImpl
*This
= impl_from_IMediaEventEx(iface
);
4970 TRACE("(%p/%p)->()\n", This
, iface
);
4972 return IUnknown_AddRef(This
->outer_unk
);
4975 static ULONG WINAPI
MediaEvent_Release(IMediaEventEx
*iface
)
4977 IFilterGraphImpl
*This
= impl_from_IMediaEventEx(iface
);
4979 TRACE("(%p/%p)->()\n", This
, iface
);
4981 return IUnknown_Release(This
->outer_unk
);
4984 /*** IDispatch methods ***/
4985 static HRESULT WINAPI
MediaEvent_GetTypeInfoCount(IMediaEventEx
*iface
, UINT
*pctinfo
)
4987 IFilterGraphImpl
*This
= impl_from_IMediaEventEx(iface
);
4989 TRACE("(%p/%p)->(%p): stub !!!\n", This
, iface
, pctinfo
);
4994 static HRESULT WINAPI
MediaEvent_GetTypeInfo(IMediaEventEx
*iface
, UINT iTInfo
, LCID lcid
,
4995 ITypeInfo
**ppTInfo
)
4997 IFilterGraphImpl
*This
= impl_from_IMediaEventEx(iface
);
4999 TRACE("(%p/%p)->(%d, %d, %p): stub !!!\n", This
, iface
, iTInfo
, lcid
, ppTInfo
);
5004 static HRESULT WINAPI
MediaEvent_GetIDsOfNames(IMediaEventEx
*iface
, REFIID riid
,
5005 LPOLESTR
*rgszNames
, UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
5007 IFilterGraphImpl
*This
= impl_from_IMediaEventEx(iface
);
5009 TRACE("(%p/%p)->(%s (%p), %p, %d, %d, %p): stub !!!\n", This
, iface
, debugstr_guid(riid
), riid
, rgszNames
, cNames
, lcid
, rgDispId
);
5014 static HRESULT WINAPI
MediaEvent_Invoke(IMediaEventEx
*iface
, DISPID dispIdMember
, REFIID riid
,
5015 LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
, VARIANT
*pVarResult
, EXCEPINFO
*pExepInfo
,
5018 IFilterGraphImpl
*This
= impl_from_IMediaEventEx(iface
);
5020 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
);
5025 /*** IMediaEvent methods ***/
5026 static HRESULT WINAPI
MediaEvent_GetEventHandle(IMediaEventEx
*iface
, OAEVENT
*hEvent
)
5028 IFilterGraphImpl
*This
= impl_from_IMediaEventEx(iface
);
5030 TRACE("(%p/%p)->(%p)\n", This
, iface
, hEvent
);
5032 *hEvent
= (OAEVENT
)This
->evqueue
.msg_event
;
5037 static HRESULT WINAPI
MediaEvent_GetEvent(IMediaEventEx
*iface
, LONG
*lEventCode
, LONG_PTR
*lParam1
,
5038 LONG_PTR
*lParam2
, LONG msTimeout
)
5040 IFilterGraphImpl
*This
= impl_from_IMediaEventEx(iface
);
5043 TRACE("(%p/%p)->(%p, %p, %p, %d)\n", This
, iface
, lEventCode
, lParam1
, lParam2
, msTimeout
);
5045 if (EventsQueue_GetEvent(&This
->evqueue
, &evt
, msTimeout
))
5047 *lEventCode
= evt
.lEventCode
;
5048 *lParam1
= evt
.lParam1
;
5049 *lParam2
= evt
.lParam2
;
5057 static HRESULT WINAPI
MediaEvent_WaitForCompletion(IMediaEventEx
*iface
, LONG msTimeout
,
5060 IFilterGraphImpl
*This
= impl_from_IMediaEventEx(iface
);
5062 TRACE("(%p/%p)->(%d, %p)\n", This
, iface
, msTimeout
, pEvCode
);
5064 if (This
->state
!= State_Running
)
5065 return VFW_E_WRONG_STATE
;
5067 if (WaitForSingleObject(This
->hEventCompletion
, msTimeout
) == WAIT_OBJECT_0
)
5069 *pEvCode
= This
->CompletionStatus
;
5077 static HRESULT WINAPI
MediaEvent_CancelDefaultHandling(IMediaEventEx
*iface
, LONG lEvCode
)
5079 IFilterGraphImpl
*This
= impl_from_IMediaEventEx(iface
);
5081 TRACE("(%p/%p)->(%d)\n", This
, iface
, lEvCode
);
5083 if (lEvCode
== EC_COMPLETE
)
5084 This
->HandleEcComplete
= FALSE
;
5085 else if (lEvCode
== EC_REPAINT
)
5086 This
->HandleEcRepaint
= FALSE
;
5087 else if (lEvCode
== EC_CLOCK_CHANGED
)
5088 This
->HandleEcClockChanged
= FALSE
;
5095 static HRESULT WINAPI
MediaEvent_RestoreDefaultHandling(IMediaEventEx
*iface
, LONG lEvCode
)
5097 IFilterGraphImpl
*This
= impl_from_IMediaEventEx(iface
);
5099 TRACE("(%p/%p)->(%d)\n", This
, iface
, lEvCode
);
5101 if (lEvCode
== EC_COMPLETE
)
5102 This
->HandleEcComplete
= TRUE
;
5103 else if (lEvCode
== EC_REPAINT
)
5104 This
->HandleEcRepaint
= TRUE
;
5105 else if (lEvCode
== EC_CLOCK_CHANGED
)
5106 This
->HandleEcClockChanged
= TRUE
;
5113 static HRESULT WINAPI
MediaEvent_FreeEventParams(IMediaEventEx
*iface
, LONG lEvCode
,
5114 LONG_PTR lParam1
, LONG_PTR lParam2
)
5116 IFilterGraphImpl
*This
= impl_from_IMediaEventEx(iface
);
5118 TRACE("(%p/%p)->(%d, %08lx, %08lx): stub !!!\n", This
, iface
, lEvCode
, lParam1
, lParam2
);
5123 /*** IMediaEventEx methods ***/
5124 static HRESULT WINAPI
MediaEvent_SetNotifyWindow(IMediaEventEx
*iface
, OAHWND hwnd
, LONG lMsg
,
5125 LONG_PTR lInstanceData
)
5127 IFilterGraphImpl
*This
= impl_from_IMediaEventEx(iface
);
5129 TRACE("(%p/%p)->(%08lx, %d, %08lx)\n", This
, iface
, hwnd
, lMsg
, lInstanceData
);
5131 This
->notif
.hWnd
= (HWND
)hwnd
;
5132 This
->notif
.msg
= lMsg
;
5133 This
->notif
.instance
= lInstanceData
;
5138 static HRESULT WINAPI
MediaEvent_SetNotifyFlags(IMediaEventEx
*iface
, LONG lNoNotifyFlags
)
5140 IFilterGraphImpl
*This
= impl_from_IMediaEventEx(iface
);
5142 TRACE("(%p/%p)->(%d)\n", This
, iface
, lNoNotifyFlags
);
5144 if ((lNoNotifyFlags
!= 0) && (lNoNotifyFlags
!= 1))
5145 return E_INVALIDARG
;
5147 This
->notif
.disabled
= lNoNotifyFlags
;
5152 static HRESULT WINAPI
MediaEvent_GetNotifyFlags(IMediaEventEx
*iface
, LONG
*lplNoNotifyFlags
)
5154 IFilterGraphImpl
*This
= impl_from_IMediaEventEx(iface
);
5156 TRACE("(%p/%p)->(%p)\n", This
, iface
, lplNoNotifyFlags
);
5158 if (!lplNoNotifyFlags
)
5161 *lplNoNotifyFlags
= This
->notif
.disabled
;
5167 static const IMediaEventExVtbl IMediaEventEx_VTable
=
5169 MediaEvent_QueryInterface
,
5172 MediaEvent_GetTypeInfoCount
,
5173 MediaEvent_GetTypeInfo
,
5174 MediaEvent_GetIDsOfNames
,
5176 MediaEvent_GetEventHandle
,
5177 MediaEvent_GetEvent
,
5178 MediaEvent_WaitForCompletion
,
5179 MediaEvent_CancelDefaultHandling
,
5180 MediaEvent_RestoreDefaultHandling
,
5181 MediaEvent_FreeEventParams
,
5182 MediaEvent_SetNotifyWindow
,
5183 MediaEvent_SetNotifyFlags
,
5184 MediaEvent_GetNotifyFlags
5188 static inline IFilterGraphImpl
*impl_from_IMediaFilter(IMediaFilter
*iface
)
5190 return CONTAINING_RECORD(iface
, IFilterGraphImpl
, IMediaFilter_iface
);
5193 static HRESULT WINAPI
MediaFilter_QueryInterface(IMediaFilter
*iface
, REFIID riid
, void **ppv
)
5195 IFilterGraphImpl
*This
= impl_from_IMediaFilter(iface
);
5197 return IUnknown_QueryInterface(This
->outer_unk
, riid
, ppv
);
5200 static ULONG WINAPI
MediaFilter_AddRef(IMediaFilter
*iface
)
5202 IFilterGraphImpl
*This
= impl_from_IMediaFilter(iface
);
5204 return IUnknown_AddRef(This
->outer_unk
);
5207 static ULONG WINAPI
MediaFilter_Release(IMediaFilter
*iface
)
5209 IFilterGraphImpl
*This
= impl_from_IMediaFilter(iface
);
5211 return IUnknown_Release(This
->outer_unk
);
5214 static HRESULT WINAPI
MediaFilter_GetClassID(IMediaFilter
*iface
, CLSID
* pClassID
)
5216 FIXME("(%p): stub\n", pClassID
);
5221 static HRESULT WINAPI
MediaFilter_Stop(IMediaFilter
*iface
)
5223 IFilterGraphImpl
*This
= impl_from_IMediaFilter(iface
);
5225 return MediaControl_Stop(&This
->IMediaControl_iface
);
5228 static HRESULT WINAPI
MediaFilter_Pause(IMediaFilter
*iface
)
5230 IFilterGraphImpl
*This
= impl_from_IMediaFilter(iface
);
5232 return MediaControl_Pause(&This
->IMediaControl_iface
);
5235 static HRESULT WINAPI
MediaFilter_Run(IMediaFilter
*iface
, REFERENCE_TIME tStart
)
5237 IFilterGraphImpl
*This
= impl_from_IMediaFilter(iface
);
5240 FIXME("Run called with non-null tStart: %x%08x\n",
5241 (int)(tStart
>>32), (int)tStart
);
5243 return MediaControl_Run(&This
->IMediaControl_iface
);
5246 static HRESULT WINAPI
MediaFilter_GetState(IMediaFilter
*iface
, DWORD dwMsTimeout
,
5247 FILTER_STATE
*pState
)
5249 IFilterGraphImpl
*This
= impl_from_IMediaFilter(iface
);
5251 return MediaControl_GetState(&This
->IMediaControl_iface
, dwMsTimeout
, (OAFilterState
*)pState
);
5254 static HRESULT WINAPI
MediaFilter_SetSyncSource(IMediaFilter
*iface
, IReferenceClock
*pClock
)
5256 IFilterGraphImpl
*This
= impl_from_IMediaFilter(iface
);
5260 TRACE("(%p/%p)->(%p)\n", iface
, This
, pClock
);
5262 EnterCriticalSection(&This
->cs
);
5264 for (i
= 0;i
< This
->nFilters
;i
++)
5266 hr
= IBaseFilter_SetSyncSource(This
->ppFiltersInGraph
[i
], pClock
);
5274 IBaseFilter_SetSyncSource(This
->ppFiltersInGraph
[i
], This
->refClock
);
5279 IReferenceClock_Release(This
->refClock
);
5280 This
->refClock
= pClock
;
5282 IReferenceClock_AddRef(This
->refClock
);
5283 This
->defaultclock
= FALSE
;
5285 if (This
->HandleEcClockChanged
)
5287 IMediaEventSink
*pEventSink
;
5290 eshr
= IMediaFilter_QueryInterface(iface
, &IID_IMediaEventSink
, (void **)&pEventSink
);
5291 if (SUCCEEDED(eshr
))
5293 IMediaEventSink_Notify(pEventSink
, EC_CLOCK_CHANGED
, 0, 0);
5294 IMediaEventSink_Release(pEventSink
);
5299 LeaveCriticalSection(&This
->cs
);
5304 static HRESULT WINAPI
MediaFilter_GetSyncSource(IMediaFilter
*iface
, IReferenceClock
**ppClock
)
5306 IFilterGraphImpl
*This
= impl_from_IMediaFilter(iface
);
5308 TRACE("(%p/%p)->(%p)\n", iface
, This
, ppClock
);
5313 EnterCriticalSection(&This
->cs
);
5315 *ppClock
= This
->refClock
;
5317 IReferenceClock_AddRef(*ppClock
);
5319 LeaveCriticalSection(&This
->cs
);
5324 static const IMediaFilterVtbl IMediaFilter_VTable
=
5326 MediaFilter_QueryInterface
,
5328 MediaFilter_Release
,
5329 MediaFilter_GetClassID
,
5333 MediaFilter_GetState
,
5334 MediaFilter_SetSyncSource
,
5335 MediaFilter_GetSyncSource
5338 static inline IFilterGraphImpl
*impl_from_IMediaEventSink(IMediaEventSink
*iface
)
5340 return CONTAINING_RECORD(iface
, IFilterGraphImpl
, IMediaEventSink_iface
);
5343 static HRESULT WINAPI
MediaEventSink_QueryInterface(IMediaEventSink
*iface
, REFIID riid
, void **ppv
)
5345 IFilterGraphImpl
*This
= impl_from_IMediaEventSink(iface
);
5347 return IUnknown_QueryInterface(This
->outer_unk
, riid
, ppv
);
5350 static ULONG WINAPI
MediaEventSink_AddRef(IMediaEventSink
*iface
)
5352 IFilterGraphImpl
*This
= impl_from_IMediaEventSink(iface
);
5354 return IUnknown_AddRef(This
->outer_unk
);
5357 static ULONG WINAPI
MediaEventSink_Release(IMediaEventSink
*iface
)
5359 IFilterGraphImpl
*This
= impl_from_IMediaEventSink(iface
);
5361 return IUnknown_Release(This
->outer_unk
);
5364 static HRESULT WINAPI
MediaEventSink_Notify(IMediaEventSink
*iface
, LONG EventCode
,
5365 LONG_PTR EventParam1
, LONG_PTR EventParam2
)
5367 IFilterGraphImpl
*This
= impl_from_IMediaEventSink(iface
);
5370 TRACE("(%p/%p)->(%d, %ld, %ld)\n", This
, iface
, EventCode
, EventParam1
, EventParam2
);
5372 /* We need thread safety here, let's use the events queue's one */
5373 EnterCriticalSection(&This
->evqueue
.msg_crst
);
5375 if ((EventCode
== EC_COMPLETE
) && This
->HandleEcComplete
)
5377 TRACE("Process EC_COMPLETE notification\n");
5378 if (++This
->EcCompleteCount
== This
->nRenderers
)
5380 evt
.lEventCode
= EC_COMPLETE
;
5383 TRACE("Send EC_COMPLETE to app\n");
5384 EventsQueue_PutEvent(&This
->evqueue
, &evt
);
5385 if (!This
->notif
.disabled
&& This
->notif
.hWnd
)
5387 TRACE("Send Window message\n");
5388 PostMessageW(This
->notif
.hWnd
, This
->notif
.msg
, 0, This
->notif
.instance
);
5390 This
->CompletionStatus
= EC_COMPLETE
;
5391 SetEvent(This
->hEventCompletion
);
5394 else if ((EventCode
== EC_REPAINT
) && This
->HandleEcRepaint
)
5396 /* FIXME: Not handled yet */
5400 evt
.lEventCode
= EventCode
;
5401 evt
.lParam1
= EventParam1
;
5402 evt
.lParam2
= EventParam2
;
5403 EventsQueue_PutEvent(&This
->evqueue
, &evt
);
5404 if (!This
->notif
.disabled
&& This
->notif
.hWnd
)
5405 PostMessageW(This
->notif
.hWnd
, This
->notif
.msg
, 0, This
->notif
.instance
);
5408 LeaveCriticalSection(&This
->evqueue
.msg_crst
);
5412 static const IMediaEventSinkVtbl IMediaEventSink_VTable
=
5414 MediaEventSink_QueryInterface
,
5415 MediaEventSink_AddRef
,
5416 MediaEventSink_Release
,
5417 MediaEventSink_Notify
5420 static inline IFilterGraphImpl
*impl_from_IGraphConfig(IGraphConfig
*iface
)
5422 return CONTAINING_RECORD(iface
, IFilterGraphImpl
, IGraphConfig_iface
);
5425 static HRESULT WINAPI
GraphConfig_QueryInterface(IGraphConfig
*iface
, REFIID riid
, void **ppv
)
5427 IFilterGraphImpl
*This
= impl_from_IGraphConfig(iface
);
5429 return IUnknown_QueryInterface(This
->outer_unk
, riid
, ppv
);
5432 static ULONG WINAPI
GraphConfig_AddRef(IGraphConfig
*iface
)
5434 IFilterGraphImpl
*This
= impl_from_IGraphConfig(iface
);
5436 return IUnknown_AddRef(This
->outer_unk
);
5439 static ULONG WINAPI
GraphConfig_Release(IGraphConfig
*iface
)
5441 IFilterGraphImpl
*This
= impl_from_IGraphConfig(iface
);
5443 return IUnknown_Release(This
->outer_unk
);
5446 static HRESULT WINAPI
GraphConfig_Reconnect(IGraphConfig
*iface
, IPin
*pOutputPin
, IPin
*pInputPin
,
5447 const AM_MEDIA_TYPE
*pmtFirstConnection
, IBaseFilter
*pUsingFilter
, HANDLE hAbortEvent
,
5450 IFilterGraphImpl
*This
= impl_from_IGraphConfig(iface
);
5452 FIXME("(%p)->(%p, %p, %p, %p, %p, %x): stub!\n", This
, pOutputPin
, pInputPin
, pmtFirstConnection
, pUsingFilter
, hAbortEvent
, dwFlags
);
5457 static HRESULT WINAPI
GraphConfig_Reconfigure(IGraphConfig
*iface
, IGraphConfigCallback
*pCallback
,
5458 void *pvContext
, DWORD dwFlags
, HANDLE hAbortEvent
)
5460 IFilterGraphImpl
*This
= impl_from_IGraphConfig(iface
);
5463 WARN("(%p)->(%p, %p, %x, %p): partial stub!\n", This
, pCallback
, pvContext
, dwFlags
, hAbortEvent
);
5466 FIXME("The parameter hAbortEvent is not handled!\n");
5468 EnterCriticalSection(&This
->cs
);
5470 hr
= IGraphConfigCallback_Reconfigure(pCallback
, pvContext
, dwFlags
);
5472 LeaveCriticalSection(&This
->cs
);
5477 static HRESULT WINAPI
GraphConfig_AddFilterToCache(IGraphConfig
*iface
, IBaseFilter
*pFilter
)
5479 IFilterGraphImpl
*This
= impl_from_IGraphConfig(iface
);
5481 FIXME("(%p)->(%p): stub!\n", This
, pFilter
);
5486 static HRESULT WINAPI
GraphConfig_EnumCacheFilter(IGraphConfig
*iface
, IEnumFilters
**pEnum
)
5488 IFilterGraphImpl
*This
= impl_from_IGraphConfig(iface
);
5490 FIXME("(%p)->(%p): stub!\n", This
, pEnum
);
5495 static HRESULT WINAPI
GraphConfig_RemoveFilterFromCache(IGraphConfig
*iface
, IBaseFilter
*pFilter
)
5497 IFilterGraphImpl
*This
= impl_from_IGraphConfig(iface
);
5499 FIXME("(%p)->(%p): stub!\n", This
, pFilter
);
5504 static HRESULT WINAPI
GraphConfig_GetStartTime(IGraphConfig
*iface
, REFERENCE_TIME
*prtStart
)
5506 IFilterGraphImpl
*This
= impl_from_IGraphConfig(iface
);
5508 FIXME("(%p)->(%p): stub!\n", This
, prtStart
);
5513 static HRESULT WINAPI
GraphConfig_PushThroughData(IGraphConfig
*iface
, IPin
*pOutputPin
,
5514 IPinConnection
*pConnection
, HANDLE hEventAbort
)
5516 IFilterGraphImpl
*This
= impl_from_IGraphConfig(iface
);
5518 FIXME("(%p)->(%p, %p, %p): stub!\n", This
, pOutputPin
, pConnection
, hEventAbort
);
5523 static HRESULT WINAPI
GraphConfig_SetFilterFlags(IGraphConfig
*iface
, IBaseFilter
*pFilter
,
5526 IFilterGraphImpl
*This
= impl_from_IGraphConfig(iface
);
5528 FIXME("(%p)->(%p, %x): stub!\n", This
, pFilter
, dwFlags
);
5533 static HRESULT WINAPI
GraphConfig_GetFilterFlags(IGraphConfig
*iface
, IBaseFilter
*pFilter
,
5536 IFilterGraphImpl
*This
= impl_from_IGraphConfig(iface
);
5538 FIXME("(%p)->(%p, %p): stub!\n", This
, pFilter
, dwFlags
);
5543 static HRESULT WINAPI
GraphConfig_RemoveFilterEx(IGraphConfig
*iface
, IBaseFilter
*pFilter
,
5546 IFilterGraphImpl
*This
= impl_from_IGraphConfig(iface
);
5548 FIXME("(%p)->(%p, %x): stub!\n", This
, pFilter
, dwFlags
);
5553 static const IGraphConfigVtbl IGraphConfig_VTable
=
5555 GraphConfig_QueryInterface
,
5557 GraphConfig_Release
,
5558 GraphConfig_Reconnect
,
5559 GraphConfig_Reconfigure
,
5560 GraphConfig_AddFilterToCache
,
5561 GraphConfig_EnumCacheFilter
,
5562 GraphConfig_RemoveFilterFromCache
,
5563 GraphConfig_GetStartTime
,
5564 GraphConfig_PushThroughData
,
5565 GraphConfig_SetFilterFlags
,
5566 GraphConfig_GetFilterFlags
,
5567 GraphConfig_RemoveFilterEx
5570 static inline IFilterGraphImpl
*impl_from_IGraphVersion(IGraphVersion
*iface
)
5572 return CONTAINING_RECORD(iface
, IFilterGraphImpl
, IGraphVersion_iface
);
5575 static HRESULT WINAPI
GraphVersion_QueryInterface(IGraphVersion
*iface
, REFIID riid
, void **ppv
)
5577 IFilterGraphImpl
*This
= impl_from_IGraphVersion(iface
);
5579 return IUnknown_QueryInterface(This
->outer_unk
, riid
, ppv
);
5582 static ULONG WINAPI
GraphVersion_AddRef(IGraphVersion
*iface
)
5584 IFilterGraphImpl
*This
= impl_from_IGraphVersion(iface
);
5586 return IUnknown_AddRef(This
->outer_unk
);
5589 static ULONG WINAPI
GraphVersion_Release(IGraphVersion
*iface
)
5591 IFilterGraphImpl
*This
= impl_from_IGraphVersion(iface
);
5593 return IUnknown_Release(This
->outer_unk
);
5596 static HRESULT WINAPI
GraphVersion_QueryVersion(IGraphVersion
*iface
, LONG
*pVersion
)
5598 IFilterGraphImpl
*This
= impl_from_IGraphVersion(iface
);
5603 TRACE("(%p)->(%p): current version %i\n", This
, pVersion
, This
->version
);
5605 *pVersion
= This
->version
;
5609 static const IGraphVersionVtbl IGraphVersion_VTable
=
5611 GraphVersion_QueryInterface
,
5612 GraphVersion_AddRef
,
5613 GraphVersion_Release
,
5614 GraphVersion_QueryVersion
,
5617 static const IUnknownVtbl IInner_VTable
=
5619 FilterGraphInner_QueryInterface
,
5620 FilterGraphInner_AddRef
,
5621 FilterGraphInner_Release
5624 /* This is the only function that actually creates a FilterGraph class... */
5625 HRESULT
FilterGraph_create(IUnknown
*pUnkOuter
, LPVOID
*ppObj
)
5627 IFilterGraphImpl
*fimpl
;
5630 TRACE("(%p,%p)\n", pUnkOuter
, ppObj
);
5634 fimpl
= CoTaskMemAlloc(sizeof(*fimpl
));
5635 fimpl
->defaultclock
= TRUE
;
5636 fimpl
->IUnknown_inner
.lpVtbl
= &IInner_VTable
;
5637 fimpl
->IFilterGraph2_iface
.lpVtbl
= &IFilterGraph2_VTable
;
5638 fimpl
->IMediaControl_iface
.lpVtbl
= &IMediaControl_VTable
;
5639 fimpl
->IMediaSeeking_iface
.lpVtbl
= &IMediaSeeking_VTable
;
5640 fimpl
->IBasicAudio_iface
.lpVtbl
= &IBasicAudio_VTable
;
5641 fimpl
->IBasicVideo2_iface
.lpVtbl
= &IBasicVideo_VTable
;
5642 fimpl
->IVideoWindow_iface
.lpVtbl
= &IVideoWindow_VTable
;
5643 fimpl
->IMediaEventEx_iface
.lpVtbl
= &IMediaEventEx_VTable
;
5644 fimpl
->IMediaFilter_iface
.lpVtbl
= &IMediaFilter_VTable
;
5645 fimpl
->IMediaEventSink_iface
.lpVtbl
= &IMediaEventSink_VTable
;
5646 fimpl
->IGraphConfig_iface
.lpVtbl
= &IGraphConfig_VTable
;
5647 fimpl
->IMediaPosition_iface
.lpVtbl
= &IMediaPosition_VTable
;
5648 fimpl
->IObjectWithSite_iface
.lpVtbl
= &IObjectWithSite_VTable
;
5649 fimpl
->IGraphVersion_iface
.lpVtbl
= &IGraphVersion_VTable
;
5651 fimpl
->ppFiltersInGraph
= NULL
;
5652 fimpl
->pFilterNames
= NULL
;
5653 fimpl
->nFilters
= 0;
5654 fimpl
->filterCapacity
= 0;
5655 fimpl
->nameIndex
= 1;
5656 fimpl
->refClock
= NULL
;
5657 fimpl
->hEventCompletion
= CreateEventW(0, TRUE
, FALSE
, 0);
5658 fimpl
->HandleEcComplete
= TRUE
;
5659 fimpl
->HandleEcRepaint
= TRUE
;
5660 fimpl
->HandleEcClockChanged
= TRUE
;
5661 fimpl
->notif
.hWnd
= 0;
5662 fimpl
->notif
.disabled
= FALSE
;
5663 fimpl
->nRenderers
= 0;
5664 fimpl
->EcCompleteCount
= 0;
5665 fimpl
->refClockProvider
= NULL
;
5666 fimpl
->state
= State_Stopped
;
5667 fimpl
->pSite
= NULL
;
5668 EventsQueue_Init(&fimpl
->evqueue
);
5669 InitializeCriticalSection(&fimpl
->cs
);
5670 fimpl
->cs
.DebugInfo
->Spare
[0] = (DWORD_PTR
)(__FILE__
": IFilterGraphImpl.cs");
5671 fimpl
->nItfCacheEntries
= 0;
5672 memcpy(&fimpl
->timeformatseek
, &TIME_FORMAT_MEDIA_TIME
, sizeof(GUID
));
5673 fimpl
->start_time
= fimpl
->pause_time
= 0;
5674 fimpl
->punkFilterMapper2
= NULL
;
5675 fimpl
->recursioncount
= 0;
5679 fimpl
->outer_unk
= pUnkOuter
;
5681 fimpl
->outer_unk
= &fimpl
->IUnknown_inner
;
5683 /* create Filtermapper aggregated. */
5684 hr
= CoCreateInstance(&CLSID_FilterMapper2
, fimpl
->outer_unk
, CLSCTX_INPROC_SERVER
,
5685 &IID_IUnknown
, (void**)&fimpl
->punkFilterMapper2
);
5688 hr
= IUnknown_QueryInterface(fimpl
->punkFilterMapper2
, &IID_IFilterMapper2
,
5689 (void**)&fimpl
->pFilterMapper2
);
5692 /* Release controlling IUnknown - compensate refcount increase from caching IFilterMapper2 interface. */
5693 IUnknown_Release(fimpl
->outer_unk
);
5696 ERR("Unable to create filter mapper (%x)\n", hr
);
5697 if (fimpl
->punkFilterMapper2
) IUnknown_Release(fimpl
->punkFilterMapper2
);
5698 CloseHandle(fimpl
->hEventCompletion
);
5699 EventsQueue_Destroy(&fimpl
->evqueue
);
5700 fimpl
->cs
.DebugInfo
->Spare
[0] = 0;
5701 DeleteCriticalSection(&fimpl
->cs
);
5702 CoTaskMemFree(fimpl
);
5706 *ppObj
= &fimpl
->IUnknown_inner
;
5710 HRESULT
FilterGraphNoThread_create(IUnknown
*pUnkOuter
, LPVOID
*ppObj
)
5712 FIXME("CLSID_FilterGraphNoThread partially implemented - Forwarding to CLSID_FilterGraph\n");
5713 return FilterGraph_create(pUnkOuter
, ppObj
);