1 /* DirectShow FilterGraph object (QUARTZ.DLL)
3 * Copyright 2002 Lionel Ulmer
4 * Copyright 2004 Christian Costa
6 * This file contains the (internal) driver registration functions,
7 * driver enumeration APIs and DirectDraw creation functions.
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
35 #include "wine/debug.h"
36 #include "quartz_private.h"
42 #include "wine/unicode.h"
45 WINE_DEFAULT_DEBUG_CHANNEL(quartz
);
48 HWND hWnd
; /* Target window */
49 long msg
; /* User window message */
50 long instance
; /* User data */
51 int disabled
; /* Disabled messages posting */
55 long lEventCode
; /* Event code */
56 LONG_PTR lParam1
; /* Param1 */
57 LONG_PTR lParam2
; /* Param2 */
60 /* messages ring implementation for queuing events (taken from winmm) */
61 #define EVENTS_RING_BUFFER_INCREMENT 64
67 CRITICAL_SECTION msg_crst
;
68 HANDLE msg_event
; /* Signaled for no empty queue */
71 static int EventsQueue_Init(EventsQueue
* omr
)
75 omr
->msg_event
= CreateEventW(NULL
, TRUE
, FALSE
, NULL
);
76 omr
->ring_buffer_size
= EVENTS_RING_BUFFER_INCREMENT
;
77 omr
->messages
= CoTaskMemAlloc(omr
->ring_buffer_size
* sizeof(Event
));
78 ZeroMemory(omr
->messages
, omr
->ring_buffer_size
* sizeof(Event
));
80 InitializeCriticalSection(&omr
->msg_crst
);
81 omr
->msg_crst
.DebugInfo
->Spare
[0] = (DWORD_PTR
)(__FILE__
": EventsQueue.msg_crst");
85 static int EventsQueue_Destroy(EventsQueue
* omr
)
87 CloseHandle(omr
->msg_event
);
88 CoTaskMemFree(omr
->messages
);
89 omr
->msg_crst
.DebugInfo
->Spare
[0] = 0;
90 DeleteCriticalSection(&omr
->msg_crst
);
94 static int EventsQueue_PutEvent(EventsQueue
* omr
, const Event
* evt
)
96 EnterCriticalSection(&omr
->msg_crst
);
97 if ((omr
->msg_toget
== ((omr
->msg_tosave
+ 1) % omr
->ring_buffer_size
)))
99 int old_ring_buffer_size
= omr
->ring_buffer_size
;
100 omr
->ring_buffer_size
+= EVENTS_RING_BUFFER_INCREMENT
;
101 TRACE("omr->ring_buffer_size=%d\n",omr
->ring_buffer_size
);
102 omr
->messages
= HeapReAlloc(GetProcessHeap(),0,omr
->messages
, omr
->ring_buffer_size
* sizeof(Event
));
103 /* Now we need to rearrange the ring buffer so that the new
104 buffers just allocated are in between omr->msg_tosave and
107 if (omr
->msg_tosave
< omr
->msg_toget
)
109 memmove(&(omr
->messages
[omr
->msg_toget
+ EVENTS_RING_BUFFER_INCREMENT
]),
110 &(omr
->messages
[omr
->msg_toget
]),
111 sizeof(Event
)*(old_ring_buffer_size
- omr
->msg_toget
)
113 omr
->msg_toget
+= EVENTS_RING_BUFFER_INCREMENT
;
116 omr
->messages
[omr
->msg_tosave
] = *evt
;
117 SetEvent(omr
->msg_event
);
118 omr
->msg_tosave
= (omr
->msg_tosave
+ 1) % omr
->ring_buffer_size
;
119 LeaveCriticalSection(&omr
->msg_crst
);
123 static int EventsQueue_GetEvent(EventsQueue
* omr
, Event
* evt
, long msTimeOut
)
125 if (WaitForSingleObject(omr
->msg_event
, msTimeOut
) != WAIT_OBJECT_0
)
128 EnterCriticalSection(&omr
->msg_crst
);
130 if (omr
->msg_toget
== omr
->msg_tosave
) /* buffer empty ? */
132 LeaveCriticalSection(&omr
->msg_crst
);
136 *evt
= omr
->messages
[omr
->msg_toget
];
137 omr
->msg_toget
= (omr
->msg_toget
+ 1) % omr
->ring_buffer_size
;
139 /* Mark the buffer as empty if needed */
140 if (omr
->msg_toget
== omr
->msg_tosave
) /* buffer empty ? */
141 ResetEvent(omr
->msg_event
);
143 LeaveCriticalSection(&omr
->msg_crst
);
147 #define MAX_ITF_CACHE_ENTRIES 3
148 typedef struct _ITF_CACHE_ENTRY
{
154 typedef struct _IFilterGraphImpl
{
155 const IFilterGraph2Vtbl
*IFilterGraph2_vtbl
;
156 const IMediaControlVtbl
*IMediaControl_vtbl
;
157 const IMediaSeekingVtbl
*IMediaSeeking_vtbl
;
158 const IBasicAudioVtbl
*IBasicAudio_vtbl
;
159 const IBasicVideo2Vtbl
*IBasicVideo_vtbl
;
160 const IVideoWindowVtbl
*IVideoWindow_vtbl
;
161 const IMediaEventExVtbl
*IMediaEventEx_vtbl
;
162 const IMediaFilterVtbl
*IMediaFilter_vtbl
;
163 const IMediaEventSinkVtbl
*IMediaEventSink_vtbl
;
164 const IGraphConfigVtbl
*IGraphConfig_vtbl
;
165 const IMediaPositionVtbl
*IMediaPosition_vtbl
;
166 const IUnknownVtbl
* IInner_vtbl
;
167 /* IAMGraphStreams */
173 /* IRegisterServiceProvider */
174 /* IResourceMananger */
175 /* IServiceProvider */
176 /* IVideoFrameStep */
179 IUnknown
*punkFilterMapper2
;
180 IFilterMapper2
* pFilterMapper2
;
181 IBaseFilter
** ppFiltersInGraph
;
182 LPWSTR
* pFilterNames
;
186 IReferenceClock
*refClock
;
188 HANDLE hEventCompletion
;
189 int CompletionStatus
;
193 int HandleEcComplete
;
195 int HandleEcClockChanged
;
198 ITF_CACHE_ENTRY ItfCacheEntries
[MAX_ITF_CACHE_ENTRIES
];
199 int nItfCacheEntries
;
200 IUnknown
* pUnkOuter
;
206 LONGLONG stop_position
;
210 static HRESULT
Filtergraph_QueryInterface(IFilterGraphImpl
*This
,
211 REFIID riid
, LPVOID
* ppv
);
212 static ULONG
Filtergraph_AddRef(IFilterGraphImpl
*This
);
213 static ULONG
Filtergraph_Release(IFilterGraphImpl
*This
);
215 static HRESULT WINAPI
FilterGraphInner_QueryInterface(IUnknown
* iface
,
218 ICOM_THIS_MULTI(IFilterGraphImpl
, IInner_vtbl
, iface
);
219 TRACE("(%p)->(%s (%p), %p)\n", This
, debugstr_guid(riid
), riid
, ppvObj
);
221 if (This
->bAggregatable
)
222 This
->bUnkOuterValid
= TRUE
;
224 if (IsEqualGUID(&IID_IUnknown
, riid
)) {
225 *ppvObj
= &(This
->IInner_vtbl
);
226 TRACE(" returning IUnknown interface (%p)\n", *ppvObj
);
227 } else if (IsEqualGUID(&IID_IFilterGraph
, riid
) ||
228 IsEqualGUID(&IID_IFilterGraph2
, riid
) ||
229 IsEqualGUID(&IID_IGraphBuilder
, riid
)) {
230 *ppvObj
= &(This
->IFilterGraph2_vtbl
);
231 TRACE(" returning IGraphBuilder interface (%p)\n", *ppvObj
);
232 } else if (IsEqualGUID(&IID_IMediaControl
, riid
)) {
233 *ppvObj
= &(This
->IMediaControl_vtbl
);
234 TRACE(" returning IMediaControl interface (%p)\n", *ppvObj
);
235 } else if (IsEqualGUID(&IID_IMediaSeeking
, riid
)) {
236 *ppvObj
= &(This
->IMediaSeeking_vtbl
);
237 TRACE(" returning IMediaSeeking interface (%p)\n", *ppvObj
);
238 } else if (IsEqualGUID(&IID_IBasicAudio
, riid
)) {
239 *ppvObj
= &(This
->IBasicAudio_vtbl
);
240 TRACE(" returning IBasicAudio interface (%p)\n", *ppvObj
);
241 } else if (IsEqualGUID(&IID_IBasicVideo
, riid
) ||
242 IsEqualGUID(&IID_IBasicVideo2
, riid
)) {
243 *ppvObj
= &(This
->IBasicVideo_vtbl
);
244 TRACE(" returning IBasicVideo2 interface (%p)\n", *ppvObj
);
245 } else if (IsEqualGUID(&IID_IVideoWindow
, riid
)) {
246 *ppvObj
= &(This
->IVideoWindow_vtbl
);
247 TRACE(" returning IVideoWindow interface (%p)\n", *ppvObj
);
248 } else if (IsEqualGUID(&IID_IMediaEvent
, riid
) ||
249 IsEqualGUID(&IID_IMediaEventEx
, riid
)) {
250 *ppvObj
= &(This
->IMediaEventEx_vtbl
);
251 TRACE(" returning IMediaEvent(Ex) interface (%p)\n", *ppvObj
);
252 } else if (IsEqualGUID(&IID_IMediaFilter
, riid
) ||
253 IsEqualGUID(&IID_IPersist
, riid
)) {
254 *ppvObj
= &(This
->IMediaFilter_vtbl
);
255 TRACE(" returning IMediaFilter interface (%p)\n", *ppvObj
);
256 } else if (IsEqualGUID(&IID_IMediaEventSink
, riid
)) {
257 *ppvObj
= &(This
->IMediaEventSink_vtbl
);
258 TRACE(" returning IMediaEventSink interface (%p)\n", *ppvObj
);
259 } else if (IsEqualGUID(&IID_IGraphConfig
, riid
)) {
260 *ppvObj
= &(This
->IGraphConfig_vtbl
);
261 TRACE(" returning IGraphConfig interface (%p)\n", *ppvObj
);
262 } else if (IsEqualGUID(&IID_IMediaPosition
, riid
)) {
263 *ppvObj
= &(This
->IMediaPosition_vtbl
);
264 TRACE(" returning IMediaPosition interface (%p)\n", *ppvObj
);
265 } else if (IsEqualGUID(&IID_IFilterMapper
, riid
)) {
266 TRACE(" requesting IFilterMapper interface from aggregated filtermapper (%p)\n", *ppvObj
);
267 return IUnknown_QueryInterface(This
->punkFilterMapper2
, riid
, ppvObj
);
268 } else if (IsEqualGUID(&IID_IFilterMapper2
, riid
)) {
269 *ppvObj
= This
->pFilterMapper2
;
270 TRACE(" returning IFilterMapper2 interface from aggregated filtermapper (%p)\n", *ppvObj
);
273 FIXME("unknown interface %s\n", debugstr_guid(riid
));
274 return E_NOINTERFACE
;
277 IUnknown_AddRef((IUnknown
*)(*ppvObj
));
281 static ULONG WINAPI
FilterGraphInner_AddRef(IUnknown
* iface
) {
282 ICOM_THIS_MULTI(IFilterGraphImpl
, IInner_vtbl
, iface
);
283 ULONG ref
= InterlockedIncrement(&This
->ref
);
285 TRACE("(%p)->(): new ref = %d\n", This
, ref
);
290 static ULONG WINAPI
FilterGraphInner_Release(IUnknown
* iface
)
292 ICOM_THIS_MULTI(IFilterGraphImpl
, IInner_vtbl
, iface
);
293 ULONG ref
= InterlockedDecrement(&This
->ref
);
295 TRACE("(%p)->(): new ref = %d\n", This
, ref
);
300 This
->ref
= 1; /* guard against reentrancy (aggregation). */
302 IMediaControl_Stop((IMediaControl
*)&(This
->IMediaControl_vtbl
));
304 while (This
->nFilters
)
305 IFilterGraph2_RemoveFilter((IFilterGraph2
*)This
, This
->ppFiltersInGraph
[0]);
308 IReferenceClock_Release(This
->refClock
);
310 for (i
= 0; i
< This
->nItfCacheEntries
; i
++)
312 if (This
->ItfCacheEntries
[i
].iface
)
313 IUnknown_Release(This
->ItfCacheEntries
[i
].iface
);
316 /* AddRef on controlling IUnknown, to compensate for Release of cached IFilterMapper2 interface below.
318 * NOTE: Filtergraph_AddRef isn't suitable, because bUnkOuterValid may be FALSE but punkOuter non-NULL
319 * and already passed as punkOuter to filtermapper in FilterGraph_create - this will happen in case of
320 * CoCreateInstance of filtergraph with non-null pUnkOuter and REFIID other than IID_Unknown that is
321 * cleaning up after error. */
322 if (This
->pUnkOuter
) IUnknown_AddRef(This
->pUnkOuter
);
323 else IUnknown_AddRef((IUnknown
*)&This
->IInner_vtbl
);
325 IFilterMapper2_Release(This
->pFilterMapper2
);
326 IUnknown_Release(This
->punkFilterMapper2
);
328 CloseHandle(This
->hEventCompletion
);
329 EventsQueue_Destroy(&This
->evqueue
);
330 This
->cs
.DebugInfo
->Spare
[0] = 0;
331 DeleteCriticalSection(&This
->cs
);
332 CoTaskMemFree(This
->ppFiltersInGraph
);
333 CoTaskMemFree(This
->pFilterNames
);
340 /*** IUnknown methods ***/
341 static HRESULT WINAPI
FilterGraph2_QueryInterface(IFilterGraph2
*iface
,
344 ICOM_THIS_MULTI(IFilterGraphImpl
, IFilterGraph2_vtbl
, iface
);
346 TRACE("(%p/%p)->(%s (%p), %p)\n", This
, iface
, debugstr_guid(riid
), riid
, ppvObj
);
347 return Filtergraph_QueryInterface(This
, riid
, ppvObj
);
350 static ULONG WINAPI
FilterGraph2_AddRef(IFilterGraph2
*iface
) {
351 ICOM_THIS_MULTI(IFilterGraphImpl
, IFilterGraph2_vtbl
, iface
);
353 TRACE("(%p/%p)->() calling FilterGraph AddRef\n", This
, iface
);
355 return Filtergraph_AddRef(This
);
358 static ULONG WINAPI
FilterGraph2_Release(IFilterGraph2
*iface
) {
359 ICOM_THIS_MULTI(IFilterGraphImpl
, IFilterGraph2_vtbl
, iface
);
361 TRACE("(%p/%p)->() calling FilterGraph Release\n", This
, iface
);
363 return Filtergraph_Release(This
);
366 /*** IFilterGraph methods ***/
367 static HRESULT WINAPI
FilterGraph2_AddFilter(IFilterGraph2
*iface
,
368 IBaseFilter
*pFilter
,
370 ICOM_THIS_MULTI(IFilterGraphImpl
, IFilterGraph2_vtbl
, iface
);
373 WCHAR
* wszFilterName
= NULL
;
374 int duplicate_name
= FALSE
;
376 TRACE("(%p/%p)->(%p, %s (%p))\n", This
, iface
, pFilter
, debugstr_w(pName
), pName
);
381 wszFilterName
= CoTaskMemAlloc( (pName
? strlenW(pName
) + 6 : 5) * sizeof(WCHAR
) );
385 /* Check if name already exists */
386 for(i
= 0; i
< This
->nFilters
; i
++)
387 if (!strcmpW(This
->pFilterNames
[i
], pName
))
389 duplicate_name
= TRUE
;
394 /* If no name given or name already existing, generate one */
395 if (!pName
|| duplicate_name
)
397 static const WCHAR wszFmt1
[] = {'%','s',' ','%','0','4','d',0};
398 static const WCHAR wszFmt2
[] = {'%','0','4','d',0};
400 for (j
= 0; j
< 10000 ; j
++)
404 sprintfW(wszFilterName
, wszFmt1
, pName
, This
->nameIndex
);
406 sprintfW(wszFilterName
, wszFmt2
, This
->nameIndex
);
407 TRACE("Generated name %s\n", debugstr_w(wszFilterName
));
409 /* Check if the generated name already exists */
410 for(i
= 0; i
< This
->nFilters
; i
++)
411 if (!strcmpW(This
->pFilterNames
[i
], wszFilterName
))
414 /* Compute next index and exit if generated name is suitable */
415 if (This
->nameIndex
++ == 10000)
417 if (i
== This
->nFilters
)
420 /* Unable to find a suitable name */
423 CoTaskMemFree(wszFilterName
);
424 return VFW_E_DUPLICATE_NAME
;
428 memcpy(wszFilterName
, pName
, (strlenW(pName
) + 1) * sizeof(WCHAR
));
430 if (This
->nFilters
+ 1 > This
->filterCapacity
)
432 int newCapacity
= This
->filterCapacity
? 2 * This
->filterCapacity
: 1;
433 IBaseFilter
** ppNewFilters
= CoTaskMemAlloc(newCapacity
* sizeof(IBaseFilter
*));
434 LPWSTR
* pNewNames
= CoTaskMemAlloc(newCapacity
* sizeof(LPWSTR
));
435 memcpy(ppNewFilters
, This
->ppFiltersInGraph
, This
->nFilters
* sizeof(IBaseFilter
*));
436 memcpy(pNewNames
, This
->pFilterNames
, This
->nFilters
* sizeof(LPWSTR
));
437 if (This
->filterCapacity
)
439 CoTaskMemFree(This
->ppFiltersInGraph
);
440 CoTaskMemFree(This
->pFilterNames
);
442 This
->ppFiltersInGraph
= ppNewFilters
;
443 This
->pFilterNames
= pNewNames
;
444 This
->filterCapacity
= newCapacity
;
447 hr
= IBaseFilter_JoinFilterGraph(pFilter
, (IFilterGraph
*)This
, wszFilterName
);
451 IBaseFilter_AddRef(pFilter
);
452 This
->ppFiltersInGraph
[This
->nFilters
] = pFilter
;
453 This
->pFilterNames
[This
->nFilters
] = wszFilterName
;
455 IBaseFilter_SetSyncSource(pFilter
, This
->refClock
);
458 CoTaskMemFree(wszFilterName
);
460 if (SUCCEEDED(hr
) && duplicate_name
)
461 return VFW_S_DUPLICATE_NAME
;
466 static HRESULT WINAPI
FilterGraph2_RemoveFilter(IFilterGraph2
*iface
, IBaseFilter
*pFilter
)
468 ICOM_THIS_MULTI(IFilterGraphImpl
, IFilterGraph2_vtbl
, iface
);
472 TRACE("(%p/%p)->(%p)\n", This
, iface
, pFilter
);
474 /* FIXME: check graph is stopped */
476 for (i
= 0; i
< This
->nFilters
; i
++)
478 if (This
->ppFiltersInGraph
[i
] == pFilter
)
480 IEnumPins
*penumpins
= NULL
;
483 TRACE("Removing filter %s\n", debugstr_w(This
->pFilterNames
[i
]));
484 IBaseFilter_GetState(pFilter
, 0, &state
);
485 if (state
== State_Running
)
486 IBaseFilter_Pause(pFilter
);
487 if (state
!= State_Stopped
)
488 IBaseFilter_Stop(pFilter
);
490 hr
= IBaseFilter_EnumPins(pFilter
, &penumpins
);
493 while(IEnumPins_Next(penumpins
, 1, &ppin
, NULL
) == S_OK
)
497 IPin_ConnectedTo(ppin
, &victim
);
500 h
= IPin_Disconnect(victim
);
501 TRACE("Disconnect other side: %08x\n", h
);
502 if (h
== VFW_E_NOT_STOPPED
)
505 IPin_QueryPinInfo(victim
, &pinfo
);
507 IBaseFilter_GetState(pinfo
.pFilter
, 0, &state
);
508 if (state
== State_Running
)
509 IBaseFilter_Pause(pinfo
.pFilter
);
510 IBaseFilter_Stop(pinfo
.pFilter
);
511 IBaseFilter_Release(pinfo
.pFilter
);
512 h
= IPin_Disconnect(victim
);
513 TRACE("Disconnect retry: %08x\n", h
);
515 IPin_Release(victim
);
517 h
= IPin_Disconnect(ppin
);
518 TRACE("Disconnect 2: %08x\n", h
);
522 IEnumPins_Release(penumpins
);
525 hr
= IBaseFilter_JoinFilterGraph(pFilter
, NULL
, This
->pFilterNames
[i
]);
528 IBaseFilter_SetSyncSource(pFilter
, NULL
);
529 IBaseFilter_Release(pFilter
);
530 CoTaskMemFree(This
->pFilterNames
[i
]);
531 memmove(This
->ppFiltersInGraph
+i
, This
->ppFiltersInGraph
+i
+1, sizeof(IBaseFilter
*)*(This
->nFilters
- 1 - i
));
532 memmove(This
->pFilterNames
+i
, This
->pFilterNames
+i
+1, sizeof(LPWSTR
)*(This
->nFilters
- 1 - i
));
534 /* Invalidate interfaces in the cache */
535 for (i
= 0; i
< This
->nItfCacheEntries
; i
++)
536 if (pFilter
== This
->ItfCacheEntries
[i
].filter
)
538 IUnknown_Release(This
->ItfCacheEntries
[i
].iface
);
539 This
->ItfCacheEntries
[i
].iface
= NULL
;
540 This
->ItfCacheEntries
[i
].filter
= NULL
;
548 return hr
; /* FIXME: check this error code */
551 static HRESULT WINAPI
FilterGraph2_EnumFilters(IFilterGraph2
*iface
,
552 IEnumFilters
**ppEnum
) {
553 ICOM_THIS_MULTI(IFilterGraphImpl
, IFilterGraph2_vtbl
, iface
);
555 TRACE("(%p/%p)->(%p)\n", This
, iface
, ppEnum
);
557 return IEnumFiltersImpl_Construct(This
->ppFiltersInGraph
, This
->nFilters
, ppEnum
);
560 static HRESULT WINAPI
FilterGraph2_FindFilterByName(IFilterGraph2
*iface
,
562 IBaseFilter
**ppFilter
) {
563 ICOM_THIS_MULTI(IFilterGraphImpl
, IFilterGraph2_vtbl
, iface
);
566 TRACE("(%p/%p)->(%s (%p), %p)\n", This
, iface
, debugstr_w(pName
), pName
, ppFilter
);
571 for (i
= 0; i
< This
->nFilters
; i
++)
573 if (!strcmpW(pName
, This
->pFilterNames
[i
]))
575 *ppFilter
= This
->ppFiltersInGraph
[i
];
576 IBaseFilter_AddRef(*ppFilter
);
582 return VFW_E_NOT_FOUND
;
585 /* Don't allow a circular connection to form, return VFW_E_CIRCULAR_GRAPH if this would be the case.
586 * A circular connection will be formed if from the filter of the output pin, the input pin can be reached
588 static HRESULT
CheckCircularConnection(IFilterGraphImpl
*This
, IPin
*out
, IPin
*in
)
592 PIN_INFO info_out
, info_in
;
594 hr
= IPin_QueryPinInfo(out
, &info_out
);
597 if (info_out
.dir
!= PINDIR_OUTPUT
)
599 IBaseFilter_Release(info_out
.pFilter
);
603 hr
= IPin_QueryPinInfo(in
, &info_in
);
605 IBaseFilter_Release(info_in
.pFilter
);
608 if (info_in
.dir
!= PINDIR_INPUT
)
614 if (info_out
.pFilter
== info_in
.pFilter
)
615 hr
= VFW_E_CIRCULAR_GRAPH
;
621 hr
= IBaseFilter_EnumPins(info_out
.pFilter
, &enumpins
);
625 IEnumPins_Reset(enumpins
);
626 while ((hr
= IEnumPins_Next(enumpins
, 1, &test
, NULL
)) == S_OK
)
628 PIN_DIRECTION dir
= PINDIR_OUTPUT
;
629 IPin_QueryDirection(test
, &dir
);
630 if (dir
== PINDIR_INPUT
)
633 IPin_ConnectedTo(test
, &victim
);
636 hr
= CheckCircularConnection(This
, victim
, in
);
637 IPin_Release(victim
);
647 IEnumPins_Release(enumpins
);
651 IBaseFilter_Release(info_out
.pFilter
);
653 ERR("Checking filtergraph returned %08x, something's not right!\n", hr
);
656 /* Debugging filtergraphs not enabled */
662 /* NOTE: despite the implication, it doesn't matter which
663 * way round you put in the input and output pins */
664 static HRESULT WINAPI
FilterGraph2_ConnectDirect(IFilterGraph2
*iface
,
667 const AM_MEDIA_TYPE
*pmt
) {
671 ICOM_THIS_MULTI(IFilterGraphImpl
, IFilterGraph2_vtbl
, iface
);
673 TRACE("(%p/%p)->(%p, %p, %p)\n", This
, iface
, ppinIn
, ppinOut
, pmt
);
675 /* FIXME: check pins are in graph */
677 if (TRACE_ON(quartz
))
681 hr
= IPin_QueryPinInfo(ppinIn
, &PinInfo
);
685 TRACE("Filter owning first pin => %p\n", PinInfo
.pFilter
);
686 IBaseFilter_Release(PinInfo
.pFilter
);
688 hr
= IPin_QueryPinInfo(ppinOut
, &PinInfo
);
692 TRACE("Filter owning second pin => %p\n", PinInfo
.pFilter
);
693 IBaseFilter_Release(PinInfo
.pFilter
);
696 hr
= IPin_QueryDirection(ppinIn
, &dir
);
699 if (dir
== PINDIR_INPUT
)
701 hr
= CheckCircularConnection(This
, ppinOut
, ppinIn
);
703 hr
= IPin_Connect(ppinOut
, ppinIn
, pmt
);
707 hr
= CheckCircularConnection(This
, ppinIn
, ppinOut
);
709 hr
= IPin_Connect(ppinIn
, ppinOut
, pmt
);
716 static HRESULT WINAPI
FilterGraph2_Reconnect(IFilterGraph2
*iface
,
718 ICOM_THIS_MULTI(IFilterGraphImpl
, IFilterGraph2_vtbl
, iface
);
719 IPin
*pConnectedTo
= NULL
;
721 PIN_DIRECTION pindir
;
723 IPin_QueryDirection(ppin
, &pindir
);
724 hr
= IPin_ConnectedTo(ppin
, &pConnectedTo
);
726 TRACE("Querying connected to failed: %x\n", hr
);
729 IPin_Disconnect(ppin
);
730 IPin_Disconnect(pConnectedTo
);
731 if (pindir
== PINDIR_INPUT
)
732 hr
= IPin_Connect(pConnectedTo
, ppin
, NULL
);
734 hr
= IPin_Connect(ppin
, pConnectedTo
, NULL
);
735 IPin_Release(pConnectedTo
);
737 WARN("Reconnecting pins failed, pins are not connected now..\n");
738 TRACE("(%p->%p) -- %p %p -> %x\n", iface
, This
, ppin
, pConnectedTo
, hr
);
742 static HRESULT WINAPI
FilterGraph2_Disconnect(IFilterGraph2
*iface
, IPin
*ppin
)
744 ICOM_THIS_MULTI(IFilterGraphImpl
, IFilterGraph2_vtbl
, iface
);
746 TRACE("(%p/%p)->(%p)\n", This
, iface
, ppin
);
751 return IPin_Disconnect(ppin
);
754 static HRESULT WINAPI
FilterGraph2_SetDefaultSyncSource(IFilterGraph2
*iface
) {
755 ICOM_THIS_MULTI(IFilterGraphImpl
, IFilterGraph2_vtbl
, iface
);
756 IReferenceClock
*pClock
= NULL
;
759 TRACE("(%p/%p)->() semi-stub\n", iface
, This
);
761 hr
= CoCreateInstance(&CLSID_SystemClock
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IReferenceClock
, (LPVOID
*)&pClock
);
765 hr
= IMediaFilter_SetSyncSource((IMediaFilter
*)&(This
->IMediaFilter_vtbl
), pClock
);
766 IReferenceClock_Release(pClock
);
772 static HRESULT
GetFilterInfo(IMoniker
* pMoniker
, GUID
* pclsid
, VARIANT
* pvar
)
774 static const WCHAR wszClsidName
[] = {'C','L','S','I','D',0};
775 static const WCHAR wszFriendlyName
[] = {'F','r','i','e','n','d','l','y','N','a','m','e',0};
776 IPropertyBag
* pPropBagCat
= NULL
;
781 hr
= IMoniker_BindToStorage(pMoniker
, NULL
, NULL
, &IID_IPropertyBag
, (LPVOID
*)&pPropBagCat
);
784 hr
= IPropertyBag_Read(pPropBagCat
, wszClsidName
, pvar
, NULL
);
787 hr
= CLSIDFromString(V_UNION(pvar
, bstrVal
), pclsid
);
792 hr
= IPropertyBag_Read(pPropBagCat
, wszFriendlyName
, pvar
, NULL
);
795 TRACE("Moniker = %s - %s\n", debugstr_guid(pclsid
), debugstr_w(V_UNION(pvar
, bstrVal
)));
798 IPropertyBag_Release(pPropBagCat
);
803 static HRESULT
GetInternalConnections(IBaseFilter
* pfilter
, IPin
* pinputpin
, IPin
*** pppins
, ULONG
* pnb
)
808 TRACE("(%p, %p, %p, %p)\n", pfilter
, pinputpin
, pppins
, pnb
);
809 hr
= IPin_QueryInternalConnections(pinputpin
, NULL
, &nb
);
812 } else if (hr
== S_FALSE
) {
813 *pppins
= CoTaskMemAlloc(sizeof(IPin
*)*nb
);
814 hr
= IPin_QueryInternalConnections(pinputpin
, *pppins
, &nb
);
816 WARN("Error (%x)\n", hr
);
818 } else if (hr
== E_NOTIMPL
) {
819 /* Input connected to all outputs */
820 IEnumPins
* penumpins
;
823 TRACE("E_NOTIMPL\n");
824 hr
= IBaseFilter_EnumPins(pfilter
, &penumpins
);
826 WARN("filter Enumpins failed (%x)\n", hr
);
830 /* Count output pins */
831 while(IEnumPins_Next(penumpins
, 1, &ppin
, &nb
) == S_OK
) {
832 PIN_DIRECTION pindir
;
833 IPin_QueryDirection(ppin
, &pindir
);
834 if (pindir
== PINDIR_OUTPUT
)
838 *pppins
= CoTaskMemAlloc(sizeof(IPin
*)*i
);
839 /* Retrieve output pins */
840 IEnumPins_Reset(penumpins
);
842 while(IEnumPins_Next(penumpins
, 1, &ppin
, &nb
) == S_OK
) {
843 PIN_DIRECTION pindir
;
844 IPin_QueryDirection(ppin
, &pindir
);
845 if (pindir
== PINDIR_OUTPUT
)
846 (*pppins
)[i
++] = ppin
;
850 IEnumPins_Release(penumpins
);
853 WARN("Next failed (%x)\n", hr
);
856 } else if (FAILED(hr
)) {
857 WARN("Cannot get internal connection (%x)\n", hr
);
865 /*** IGraphBuilder methods ***/
866 static HRESULT WINAPI
FilterGraph2_Connect(IFilterGraph2
*iface
, IPin
*ppinOut
, IPin
*ppinIn
)
868 ICOM_THIS_MULTI(IFilterGraphImpl
, IFilterGraph2_vtbl
, iface
);
870 AM_MEDIA_TYPE
* mt
= NULL
;
871 IEnumMediaTypes
* penummt
= NULL
;
873 IEnumPins
* penumpins
;
874 IEnumMoniker
* pEnumMoniker
;
883 TRACE("(%p/%p)->(%p, %p)\n", This
, iface
, ppinOut
, ppinIn
);
885 if (TRACE_ON(quartz
))
887 hr
= IPin_QueryPinInfo(ppinIn
, &PinInfo
);
891 TRACE("Filter owning first pin => %p\n", PinInfo
.pFilter
);
892 IBaseFilter_Release(PinInfo
.pFilter
);
894 hr
= IPin_QueryPinInfo(ppinOut
, &PinInfo
);
898 TRACE("Filter owning second pin => %p\n", PinInfo
.pFilter
);
899 IBaseFilter_Release(PinInfo
.pFilter
);
902 EnterCriticalSection(&This
->cs
);
903 ++This
->recursioncount
;
904 if (This
->recursioncount
>= 5)
906 WARN("Recursion count has reached %d\n", This
->recursioncount
);
907 hr
= VFW_E_CANNOT_CONNECT
;
911 hr
= IPin_QueryDirection(ppinOut
, &dir
);
915 if (dir
== PINDIR_INPUT
)
924 hr
= CheckCircularConnection(This
, ppinOut
, ppinIn
);
928 /* Try direct connection first */
929 hr
= IPin_Connect(ppinOut
, ppinIn
, NULL
);
933 TRACE("Direct connection failed, trying to render using extra filters\n");
935 hr
= IPin_QueryPinInfo(ppinIn
, &PinInfo
);
939 hr
= IBaseFilter_GetClassID(PinInfo
.pFilter
, &FilterCLSID
);
940 IBaseFilter_Release(PinInfo
.pFilter
);
944 /* Find the appropriate transform filter than can transform the minor media type of output pin of the upstream
945 * filter to the minor mediatype of input pin of the renderer */
946 hr
= IPin_EnumMediaTypes(ppinOut
, &penummt
);
949 WARN("EnumMediaTypes (%x)\n", hr
);
953 hr
= IEnumMediaTypes_Next(penummt
, 1, &mt
, &nbmt
);
955 WARN("IEnumMediaTypes_Next (%x)\n", hr
);
961 WARN("No media type found!\n");
962 hr
= VFW_E_INVALIDMEDIATYPE
;
965 TRACE("MajorType %s\n", debugstr_guid(&mt
->majortype
));
966 TRACE("SubType %s\n", debugstr_guid(&mt
->subtype
));
968 /* Try to find a suitable filter that can connect to the pin to render */
969 tab
[0] = mt
->majortype
;
970 tab
[1] = mt
->subtype
;
971 hr
= IFilterMapper2_EnumMatchingFilters(This
->pFilterMapper2
, &pEnumMoniker
, 0, FALSE
, MERIT_UNLIKELY
, TRUE
, 1, tab
, NULL
, NULL
, FALSE
, FALSE
, 0, NULL
, NULL
, NULL
);
973 WARN("Unable to enum filters (%x)\n", hr
);
977 hr
= VFW_E_CANNOT_RENDER
;
978 while(IEnumMoniker_Next(pEnumMoniker
, 1, &pMoniker
, &nb
) == S_OK
)
983 IPin
* ppinfilter
= NULL
;
984 IBaseFilter
* pfilter
= NULL
;
986 hr
= GetFilterInfo(pMoniker
, &clsid
, &var
);
987 IMoniker_Release(pMoniker
);
989 WARN("Unable to retrieve filter info (%x)\n", hr
);
993 if (IsEqualGUID(&clsid
, &FilterCLSID
)) {
994 /* Skip filter (same as the one the output pin belongs to) */
998 hr
= CoCreateInstance(&clsid
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IBaseFilter
, (LPVOID
*)&pfilter
);
1000 WARN("Unable to create filter (%x), trying next one\n", hr
);
1004 hr
= IFilterGraph2_AddFilter(iface
, pfilter
, V_UNION(&var
, bstrVal
));
1006 WARN("Unable to add filter (%x)\n", hr
);
1007 IBaseFilter_Release(pfilter
);
1014 hr
= IBaseFilter_EnumPins(pfilter
, &penumpins
);
1016 WARN("Enumpins (%x)\n", hr
);
1020 hr
= IEnumPins_Next(penumpins
, 1, &ppinfilter
, &pin
);
1021 IEnumPins_Release(penumpins
);
1024 WARN("Obtaining next pin: (%x)\n", hr
);
1028 WARN("Cannot use this filter: no pins\n");
1032 hr
= IPin_Connect(ppinOut
, ppinfilter
, NULL
);
1034 TRACE("Cannot connect to filter (%x), trying next one\n", hr
);
1037 TRACE("Successfully connected to filter, follow chain...\n");
1039 /* Render all output pins of the filter by calling IFilterGraph2_Connect on each of them */
1040 hr
= GetInternalConnections(pfilter
, ppinfilter
, &ppins
, &nb
);
1042 if (SUCCEEDED(hr
)) {
1045 IPin_Disconnect(ppinfilter
);
1046 IPin_Disconnect(ppinOut
);
1049 TRACE("pins to consider: %d\n", nb
);
1050 for(i
= 0; i
< nb
; i
++)
1052 LPWSTR pinname
= NULL
;
1054 TRACE("Processing pin %u\n", i
);
1056 hr
= IPin_QueryId(ppins
[i
], &pinname
);
1059 if (pinname
[0] == '~')
1061 TRACE("Pinname=%s, skipping\n", debugstr_w(pinname
));
1065 hr
= IFilterGraph2_Connect(iface
, ppins
[i
], ppinIn
);
1066 CoTaskMemFree(pinname
);
1070 TRACE("Cannot connect pin %p (%x)\n", ppinfilter
, hr
);
1072 IPin_Release(ppins
[i
]);
1073 if (SUCCEEDED(hr
)) break;
1075 while (++i
< nb
) IPin_Release(ppins
[i
]);
1076 CoTaskMemFree(ppins
);
1077 IPin_Release(ppinfilter
);
1078 IBaseFilter_Release(pfilter
);
1081 IPin_Disconnect(ppinfilter
);
1082 IPin_Disconnect(ppinOut
);
1083 IFilterGraph2_RemoveFilter(iface
, pfilter
);
1091 if (ppinfilter
) IPin_Release(ppinfilter
);
1093 IFilterGraph2_RemoveFilter(iface
, pfilter
);
1094 IBaseFilter_Release(pfilter
);
1100 IEnumMediaTypes_Release(penummt
);
1102 DeleteMediaType(mt
);
1103 --This
->recursioncount
;
1104 LeaveCriticalSection(&This
->cs
);
1105 TRACE("--> %08x\n", hr
);
1106 return SUCCEEDED(hr
) ? S_OK
: hr
;
1109 static HRESULT
FilterGraph2_RenderRecurse(IFilterGraphImpl
*This
, IPin
*ppinOut
)
1111 /* This pin has been connected now, try to call render on all pins that aren't connected */
1114 IEnumPins
*enumpins
= NULL
;
1115 BOOL renderany
= FALSE
;
1116 BOOL renderall
= TRUE
;
1118 IPin_QueryPinInfo(ppinOut
, &info
);
1120 IBaseFilter_EnumPins(info
.pFilter
, &enumpins
);
1121 /* Don't need to hold a reference, IEnumPins does */
1122 IBaseFilter_Release(info
.pFilter
);
1124 IEnumPins_Reset(enumpins
);
1125 while (IEnumPins_Next(enumpins
, 1, &to
, NULL
) == S_OK
)
1127 PIN_DIRECTION dir
= PINDIR_INPUT
;
1129 IPin_QueryDirection(to
, &dir
);
1131 if (dir
== PINDIR_OUTPUT
)
1135 IPin_ConnectedTo(to
, &out
);
1139 hr
= IFilterGraph2_Render((IFilterGraph2
*)&This
->IFilterGraph2_vtbl
, to
);
1152 IEnumPins_Release(enumpins
);
1158 return VFW_S_PARTIAL_RENDER
;
1160 return VFW_E_CANNOT_RENDER
;
1163 /* Ogg hates me if I create a direct rendering method
1165 * It can only connect to a pin properly once, so use a recursive method that does
1167 * +----+ --- (PIN 1) (Render is called on this pin)
1169 * +----+ --- (PIN 2)
1171 * Enumerate possible renderers that EXACTLY match the requested type
1173 * If none is available, try to add intermediate filters that can connect to the input pin
1174 * then call Render on that intermediate pin's output pins
1175 * if it succeeds: Render returns success, if it doesn't, the intermediate filter is removed,
1176 * and another filter that can connect to the input pin is tried
1177 * if we run out of filters that can, give up and return VFW_E_CANNOT_RENDER
1178 * It's recursive, but fun!
1181 static HRESULT WINAPI
FilterGraph2_Render(IFilterGraph2
*iface
, IPin
*ppinOut
)
1183 ICOM_THIS_MULTI(IFilterGraphImpl
, IFilterGraph2_vtbl
, iface
);
1184 IEnumMediaTypes
* penummt
;
1189 IEnumMoniker
* pEnumMoniker
;
1195 TRACE("(%p/%p)->(%p)\n", This
, iface
, ppinOut
);
1197 if (TRACE_ON(quartz
))
1201 hr
= IPin_QueryPinInfo(ppinOut
, &PinInfo
);
1205 TRACE("Filter owning pin => %p\n", PinInfo
.pFilter
);
1206 IBaseFilter_Release(PinInfo
.pFilter
);
1209 /* Try to find out if there is a renderer for the specified subtype already, and use that
1211 EnterCriticalSection(&This
->cs
);
1212 for (x
= 0; x
< This
->nFilters
; ++x
)
1214 IEnumPins
*enumpins
= NULL
;
1217 hr
= IBaseFilter_EnumPins(This
->ppFiltersInGraph
[x
], &enumpins
);
1219 if (FAILED(hr
) || !enumpins
)
1222 IEnumPins_Reset(enumpins
);
1223 while (IEnumPins_Next(enumpins
, 1, &pin
, NULL
) == S_OK
)
1226 PIN_DIRECTION dir
= PINDIR_OUTPUT
;
1228 IPin_QueryDirection(pin
, &dir
);
1229 if (dir
!= PINDIR_INPUT
)
1234 IPin_ConnectedTo(pin
, &to
);
1238 hr
= IPin_Connect(ppinOut
, pin
, NULL
);
1241 TRACE("Connected successfully %p/%p, %08x look if we should render more!\n", ppinOut
, pin
, hr
);
1244 hr
= FilterGraph2_RenderRecurse(This
, pin
);
1247 IPin_Disconnect(ppinOut
);
1248 IPin_Disconnect(pin
);
1251 IEnumPins_Release(enumpins
);
1252 LeaveCriticalSection(&This
->cs
);
1255 WARN("Could not connect!\n");
1262 IEnumPins_Release(enumpins
);
1265 LeaveCriticalSection(&This
->cs
);
1267 hr
= IPin_EnumMediaTypes(ppinOut
, &penummt
);
1269 WARN("EnumMediaTypes (%x)\n", hr
);
1273 IEnumMediaTypes_Reset(penummt
);
1275 /* Looks like no existing renderer of the kind exists
1276 * Try adding new ones
1278 tab
[0] = tab
[1] = GUID_NULL
;
1279 while (SUCCEEDED(hr
))
1281 hr
= IEnumMediaTypes_Next(penummt
, 1, &mt
, &nbmt
);
1283 WARN("IEnumMediaTypes_Next (%x)\n", hr
);
1288 hr
= VFW_E_CANNOT_RENDER
;
1293 TRACE("MajorType %s\n", debugstr_guid(&mt
->majortype
));
1294 TRACE("SubType %s\n", debugstr_guid(&mt
->subtype
));
1296 /* Only enumerate once, this doesn't account for all previous ones, but this should be enough nonetheless */
1297 if (IsEqualIID(&tab
[0], &mt
->majortype
) && IsEqualIID(&tab
[1], &mt
->subtype
))
1299 DeleteMediaType(mt
);
1303 /* Try to find a suitable renderer with the same media type */
1304 tab
[0] = mt
->majortype
;
1305 tab
[1] = mt
->subtype
;
1306 hr
= IFilterMapper2_EnumMatchingFilters(This
->pFilterMapper2
, &pEnumMoniker
, 0, FALSE
, MERIT_UNLIKELY
, TRUE
, 1, tab
, NULL
, NULL
, FALSE
, FALSE
, 0, NULL
, NULL
, NULL
);
1309 WARN("Unable to enum filters (%x)\n", hr
);
1315 while (IEnumMoniker_Next(pEnumMoniker
, 1, &pMoniker
, &nb
) == S_OK
)
1320 IBaseFilter
* pfilter
= NULL
;
1321 IEnumPins
* penumpins
;
1324 hr
= GetFilterInfo(pMoniker
, &clsid
, &var
);
1325 IMoniker_Release(pMoniker
);
1327 WARN("Unable to retrieve filter info (%x)\n", hr
);
1331 hr
= CoCreateInstance(&clsid
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IBaseFilter
, (LPVOID
*)&pfilter
);
1334 WARN("Unable to create filter (%x), trying next one\n", hr
);
1338 hr
= IFilterGraph2_AddFilter(iface
, pfilter
, V_UNION(&var
, bstrVal
));
1340 WARN("Unable to add filter (%x)\n", hr
);
1341 IBaseFilter_Release(pfilter
);
1346 hr
= IBaseFilter_EnumPins(pfilter
, &penumpins
);
1348 WARN("Splitter Enumpins (%x)\n", hr
);
1351 hr
= IEnumPins_Next(penumpins
, 1, &ppinfilter
, &pin
);
1352 IEnumPins_Release(penumpins
);
1354 WARN("Next (%x)\n", hr
);
1363 /* Connect the pin to the "Renderer" */
1364 hr
= IPin_Connect(ppinOut
, ppinfilter
, NULL
);
1365 IPin_Release(ppinfilter
);
1368 WARN("Unable to connect %s to renderer (%x)\n", debugstr_w(V_UNION(&var
, bstrVal
)), hr
);
1371 TRACE("Connected, recursing %s\n", debugstr_w(V_UNION(&var
, bstrVal
)));
1375 hr
= FilterGraph2_RenderRecurse(This
, ppinfilter
);
1377 WARN("Unable to connect recursively (%x)\n", hr
);
1380 IBaseFilter_Release(pfilter
);
1386 IFilterGraph2_RemoveFilter(iface
, pfilter
);
1387 IBaseFilter_Release(pfilter
);
1389 if (SUCCEEDED(hr
)) DebugBreak();
1392 IEnumMoniker_Release(pEnumMoniker
);
1394 DeleteMediaType(mt
);
1400 IEnumMediaTypes_Release(penummt
);
1404 static HRESULT WINAPI
FilterGraph2_RenderFile(IFilterGraph2
*iface
,
1405 LPCWSTR lpcwstrFile
,
1406 LPCWSTR lpcwstrPlayList
)
1408 ICOM_THIS_MULTI(IFilterGraphImpl
, IFilterGraph2_vtbl
, iface
);
1409 static const WCHAR string
[] = {'R','e','a','d','e','r',0};
1410 IBaseFilter
* preader
= NULL
;
1411 IPin
* ppinreader
= NULL
;
1412 IEnumPins
* penumpins
= NULL
;
1414 BOOL partial
= FALSE
;
1415 HRESULT any
= FALSE
;
1417 TRACE("(%p/%p)->(%s, %s)\n", This
, iface
, debugstr_w(lpcwstrFile
), debugstr_w(lpcwstrPlayList
));
1419 if (lpcwstrPlayList
!= NULL
)
1420 return E_INVALIDARG
;
1422 hr
= IFilterGraph2_AddSourceFilter(iface
, lpcwstrFile
, string
, &preader
);
1427 hr
= IBaseFilter_EnumPins(preader
, &penumpins
);
1430 while (IEnumPins_Next(penumpins
, 1, &ppinreader
, NULL
) == S_OK
)
1434 IPin_QueryDirection(ppinreader
, &dir
);
1435 if (dir
== PINDIR_OUTPUT
)
1439 hr
= IFilterGraph2_Render(iface
, ppinreader
);
1440 TRACE("Render %08x\n", hr
);
1442 for (i
= 0; i
< This
->nFilters
; ++i
)
1443 TRACE("Filters in chain: %s\n", debugstr_w(This
->pFilterNames
[i
]));
1450 IPin_Release(ppinreader
);
1452 IEnumPins_Release(penumpins
);
1455 hr
= VFW_E_CANNOT_RENDER
;
1457 hr
= VFW_S_PARTIAL_RENDER
;
1461 IBaseFilter_Release(preader
);
1463 TRACE("--> %08x\n", hr
);
1467 /* Some filters implement their own asynchronous reader (Theoretically they all should, try to load it first */
1468 static HRESULT
GetFileSourceFilter(LPCOLESTR pszFileName
, IBaseFilter
**filter
)
1470 static const WCHAR wszReg
[] = {'M','e','d','i','a',' ','T','y','p','e','\\','E','x','t','e','n','s','i','o','n','s',0};
1475 lRet
= RegOpenKeyExW(HKEY_CLASSES_ROOT
, wszReg
, 0, KEY_READ
, &extkey
);
1476 hr
= HRESULT_FROM_WIN32(lRet
);
1480 static const WCHAR filtersource
[] = {'S','o','u','r','c','e',' ','F','i','l','t','e','r',0};
1481 WCHAR
*ext
= PathFindExtensionW(pszFileName
);
1482 WCHAR clsid_key
[39];
1484 DWORD size
= sizeof(clsid_key
);
1489 CloseHandle(extkey
);
1493 lRet
= RegOpenKeyExW(extkey
, ext
, 0, KEY_READ
, &pathkey
);
1494 hr
= HRESULT_FROM_WIN32(lRet
);
1495 CloseHandle(extkey
);
1499 lRet
= RegQueryValueExW(pathkey
, filtersource
, NULL
, NULL
, (LPBYTE
)clsid_key
, &size
);
1500 hr
= HRESULT_FROM_WIN32(lRet
);
1501 CloseHandle(pathkey
);
1505 CLSIDFromString(clsid_key
, &clsid
);
1507 TRACE("CLSID: %s\n", debugstr_guid(&clsid
));
1508 hr
= CoCreateInstance(&clsid
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IBaseFilter
, (LPVOID
*)filter
);
1511 IFileSourceFilter
*source
= NULL
;
1512 hr
= IBaseFilter_QueryInterface(*filter
, &IID_IFileSourceFilter
, (LPVOID
*)&source
);
1514 IFileSourceFilter_Release(source
);
1516 IBaseFilter_Release(*filter
);
1524 static HRESULT WINAPI
FilterGraph2_AddSourceFilter(IFilterGraph2
*iface
,
1525 LPCWSTR lpcwstrFileName
,
1526 LPCWSTR lpcwstrFilterName
,
1527 IBaseFilter
**ppFilter
) {
1528 ICOM_THIS_MULTI(IFilterGraphImpl
, IFilterGraph2_vtbl
, iface
);
1530 IBaseFilter
* preader
;
1531 IFileSourceFilter
* pfile
= NULL
;
1535 TRACE("(%p/%p)->(%s, %s, %p)\n", This
, iface
, debugstr_w(lpcwstrFileName
), debugstr_w(lpcwstrFilterName
), ppFilter
);
1537 /* Try from file name first, then fall back to default asynchronous reader */
1538 hr
= GetFileSourceFilter(lpcwstrFileName
, &preader
);
1541 hr
= CoCreateInstance(&CLSID_AsyncReader
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IBaseFilter
, (LPVOID
*)&preader
);
1543 WARN("Unable to create file source filter (%x)\n", hr
);
1547 hr
= IFilterGraph2_AddFilter(iface
, preader
, lpcwstrFilterName
);
1549 WARN("Unable add filter (%x)\n", hr
);
1550 IBaseFilter_Release(preader
);
1554 hr
= IBaseFilter_QueryInterface(preader
, &IID_IFileSourceFilter
, (LPVOID
*)&pfile
);
1556 WARN("Unable to get IFileSourceInterface (%x)\n", hr
);
1560 /* Load the file in the file source filter */
1561 hr
= IFileSourceFilter_Load(pfile
, lpcwstrFileName
, NULL
);
1563 WARN("Load (%x)\n", hr
);
1567 IFileSourceFilter_GetCurFile(pfile
, &filename
, &mt
);
1569 WARN("GetCurFile (%x)\n", hr
);
1573 TRACE("File %s\n", debugstr_w(filename
));
1574 TRACE("MajorType %s\n", debugstr_guid(&mt
.majortype
));
1575 TRACE("SubType %s\n", debugstr_guid(&mt
.subtype
));
1578 *ppFilter
= preader
;
1579 IFileSourceFilter_Release(pfile
);
1585 IFileSourceFilter_Release(pfile
);
1586 IFilterGraph2_RemoveFilter(iface
, preader
);
1587 IBaseFilter_Release(preader
);
1592 static HRESULT WINAPI
FilterGraph2_SetLogFile(IFilterGraph2
*iface
,
1594 ICOM_THIS_MULTI(IFilterGraphImpl
, IFilterGraph2_vtbl
, iface
);
1596 TRACE("(%p/%p)->(%08x): stub !!!\n", This
, iface
, (DWORD
) hFile
);
1601 static HRESULT WINAPI
FilterGraph2_Abort(IFilterGraph2
*iface
) {
1602 ICOM_THIS_MULTI(IFilterGraphImpl
, IFilterGraph2_vtbl
, iface
);
1604 TRACE("(%p/%p)->(): stub !!!\n", This
, iface
);
1609 static HRESULT WINAPI
FilterGraph2_ShouldOperationContinue(IFilterGraph2
*iface
) {
1610 ICOM_THIS_MULTI(IFilterGraphImpl
, IFilterGraph2_vtbl
, iface
);
1612 TRACE("(%p/%p)->(): stub !!!\n", This
, iface
);
1617 /*** IFilterGraph2 methods ***/
1618 static HRESULT WINAPI
FilterGraph2_AddSourceFilterForMoniker(IFilterGraph2
*iface
,
1621 LPCWSTR lpcwstrFilterName
,
1622 IBaseFilter
**ppFilter
) {
1623 ICOM_THIS_MULTI(IFilterGraphImpl
, IFilterGraph2_vtbl
, iface
);
1625 TRACE("(%p/%p)->(%p %p %s %p): stub !!!\n", This
, iface
, pMoniker
, pCtx
, debugstr_w(lpcwstrFilterName
), ppFilter
);
1630 static HRESULT WINAPI
FilterGraph2_ReconnectEx(IFilterGraph2
*iface
,
1632 const AM_MEDIA_TYPE
*pmt
) {
1633 ICOM_THIS_MULTI(IFilterGraphImpl
, IFilterGraph2_vtbl
, iface
);
1635 TRACE("(%p/%p)->(%p %p): stub !!!\n", This
, iface
, ppin
, pmt
);
1640 static HRESULT WINAPI
FilterGraph2_RenderEx(IFilterGraph2
*iface
,
1644 ICOM_THIS_MULTI(IFilterGraphImpl
, IFilterGraph2_vtbl
, iface
);
1646 TRACE("(%p/%p)->(%p %08x %p): stub !!!\n", This
, iface
, pPinOut
, dwFlags
, pvContext
);
1652 static const IFilterGraph2Vtbl IFilterGraph2_VTable
=
1654 FilterGraph2_QueryInterface
,
1655 FilterGraph2_AddRef
,
1656 FilterGraph2_Release
,
1657 FilterGraph2_AddFilter
,
1658 FilterGraph2_RemoveFilter
,
1659 FilterGraph2_EnumFilters
,
1660 FilterGraph2_FindFilterByName
,
1661 FilterGraph2_ConnectDirect
,
1662 FilterGraph2_Reconnect
,
1663 FilterGraph2_Disconnect
,
1664 FilterGraph2_SetDefaultSyncSource
,
1665 FilterGraph2_Connect
,
1666 FilterGraph2_Render
,
1667 FilterGraph2_RenderFile
,
1668 FilterGraph2_AddSourceFilter
,
1669 FilterGraph2_SetLogFile
,
1671 FilterGraph2_ShouldOperationContinue
,
1672 FilterGraph2_AddSourceFilterForMoniker
,
1673 FilterGraph2_ReconnectEx
,
1674 FilterGraph2_RenderEx
1677 /*** IUnknown methods ***/
1678 static HRESULT WINAPI
MediaControl_QueryInterface(IMediaControl
*iface
,
1681 ICOM_THIS_MULTI(IFilterGraphImpl
, IMediaControl_vtbl
, iface
);
1683 TRACE("(%p/%p)->(%s (%p), %p)\n", This
, iface
, debugstr_guid(riid
), riid
, ppvObj
);
1685 return Filtergraph_QueryInterface(This
, riid
, ppvObj
);
1688 static ULONG WINAPI
MediaControl_AddRef(IMediaControl
*iface
) {
1689 ICOM_THIS_MULTI(IFilterGraphImpl
, IMediaControl_vtbl
, iface
);
1691 TRACE("(%p/%p)->()\n", This
, iface
);
1693 return Filtergraph_AddRef(This
);
1696 static ULONG WINAPI
MediaControl_Release(IMediaControl
*iface
) {
1697 ICOM_THIS_MULTI(IFilterGraphImpl
, IMediaControl_vtbl
, iface
);
1699 TRACE("(%p/%p)->()\n", This
, iface
);
1701 return Filtergraph_Release(This
);
1705 /*** IDispatch methods ***/
1706 static HRESULT WINAPI
MediaControl_GetTypeInfoCount(IMediaControl
*iface
,
1708 ICOM_THIS_MULTI(IFilterGraphImpl
, IMediaControl_vtbl
, iface
);
1710 TRACE("(%p/%p)->(%p): stub !!!\n", This
, iface
, pctinfo
);
1715 static HRESULT WINAPI
MediaControl_GetTypeInfo(IMediaControl
*iface
,
1718 ITypeInfo
**ppTInfo
) {
1719 ICOM_THIS_MULTI(IFilterGraphImpl
, IMediaControl_vtbl
, iface
);
1721 TRACE("(%p/%p)->(%d, %d, %p): stub !!!\n", This
, iface
, iTInfo
, lcid
, ppTInfo
);
1726 static HRESULT WINAPI
MediaControl_GetIDsOfNames(IMediaControl
*iface
,
1732 ICOM_THIS_MULTI(IFilterGraphImpl
, IMediaControl_vtbl
, iface
);
1734 TRACE("(%p/%p)->(%s (%p), %p, %d, %d, %p): stub !!!\n", This
, iface
, debugstr_guid(riid
), riid
, rgszNames
, cNames
, lcid
, rgDispId
);
1739 static HRESULT WINAPI
MediaControl_Invoke(IMediaControl
*iface
,
1740 DISPID dispIdMember
,
1744 DISPPARAMS
*pDispParams
,
1746 EXCEPINFO
*pExepInfo
,
1748 ICOM_THIS_MULTI(IFilterGraphImpl
, IMediaControl_vtbl
, iface
);
1750 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
);
1755 typedef HRESULT(WINAPI
*fnFoundFilter
)(IBaseFilter
*, DWORD_PTR data
);
1757 static HRESULT
ExploreGraph(IFilterGraphImpl
* pGraph
, IPin
* pOutputPin
, fnFoundFilter FoundFilter
, DWORD_PTR data
)
1766 TRACE("%p %p\n", pGraph
, pOutputPin
);
1767 PinInfo
.pFilter
= NULL
;
1769 hr
= IPin_ConnectedTo(pOutputPin
, &pInputPin
);
1773 hr
= IPin_QueryPinInfo(pInputPin
, &PinInfo
);
1775 hr
= GetInternalConnections(PinInfo
.pFilter
, pInputPin
, &ppPins
, &nb
);
1776 IPin_Release(pInputPin
);
1783 TRACE("Reached a renderer\n");
1784 /* Count renderers for end of stream notification */
1785 pGraph
->nRenderers
++;
1789 for(i
= 0; i
< nb
; i
++)
1791 /* Explore the graph downstream from this pin
1792 * FIXME: We should prevent exploring from a pin more than once. This can happens when
1793 * several input pins are connected to the same output (a MUX for instance). */
1794 ExploreGraph(pGraph
, ppPins
[i
], FoundFilter
, data
);
1795 IPin_Release(ppPins
[i
]);
1798 CoTaskMemFree(ppPins
);
1800 TRACE("Doing stuff with filter %p\n", PinInfo
.pFilter
);
1802 FoundFilter(PinInfo
.pFilter
, data
);
1805 if (PinInfo
.pFilter
) IBaseFilter_Release(PinInfo
.pFilter
);
1809 static HRESULT WINAPI
SendRun(IBaseFilter
*pFilter
, DWORD_PTR data
)
1812 IReferenceClock
*clock
= NULL
;
1814 IBaseFilter_GetSyncSource(pFilter
, &clock
);
1817 IReferenceClock_GetTime(clock
, &time
);
1823 IReferenceClock_Release(clock
);
1826 return IBaseFilter_Run(pFilter
, time
);
1829 static HRESULT WINAPI
SendPause(IBaseFilter
*pFilter
, DWORD_PTR data
)
1831 return IBaseFilter_Pause(pFilter
);
1834 static HRESULT WINAPI
SendStop(IBaseFilter
*pFilter
, DWORD_PTR data
)
1836 return IBaseFilter_Stop(pFilter
);
1839 static HRESULT WINAPI
SendGetState(IBaseFilter
*pFilter
, DWORD_PTR data
)
1842 DWORD time_end
= data
;
1843 DWORD time_now
= GetTickCount();
1846 if (time_end
== INFINITE
)
1850 else if (time_end
> time_now
)
1852 wait
= time_end
- time_now
;
1857 return IBaseFilter_GetState(pFilter
, wait
, &state
);
1861 static HRESULT
SendFilterMessage(IMediaControl
*iface
, fnFoundFilter FoundFilter
, DWORD_PTR data
)
1863 ICOM_THIS_MULTI(IFilterGraphImpl
, IMediaControl_vtbl
, iface
);
1865 IBaseFilter
* pfilter
;
1871 TRACE("(%p/%p)->()\n", This
, iface
);
1873 /* Explorer the graph from source filters to renderers, determine renderers
1874 * number and run filters from renderers to source filters */
1875 This
->nRenderers
= 0;
1876 ResetEvent(This
->hEventCompletion
);
1878 for(i
= 0; i
< This
->nFilters
; i
++)
1881 pfilter
= This
->ppFiltersInGraph
[i
];
1882 hr
= IBaseFilter_EnumPins(pfilter
, &pEnum
);
1885 WARN("Enum pins failed %x\n", hr
);
1888 /* Check if it is a source filter */
1889 while(IEnumPins_Next(pEnum
, 1, &pPin
, &dummy
) == S_OK
)
1891 IPin_QueryDirection(pPin
, &dir
);
1893 if (dir
== PINDIR_INPUT
)
1901 TRACE("Found a source filter %p\n", pfilter
);
1902 IEnumPins_Reset(pEnum
);
1903 while(IEnumPins_Next(pEnum
, 1, &pPin
, &dummy
) == S_OK
)
1905 /* Explore the graph downstream from this pin */
1906 ExploreGraph(This
, pPin
, FoundFilter
, data
);
1909 FoundFilter(pfilter
, data
);
1911 IEnumPins_Release(pEnum
);
1917 /*** IMediaControl methods ***/
1918 static HRESULT WINAPI
MediaControl_Run(IMediaControl
*iface
) {
1919 ICOM_THIS_MULTI(IFilterGraphImpl
, IMediaControl_vtbl
, iface
);
1920 TRACE("(%p/%p)->()\n", This
, iface
);
1922 if (This
->state
== State_Running
) return S_OK
;
1924 EnterCriticalSection(&This
->cs
);
1925 if (This
->state
== State_Stopped
)
1926 This
->EcCompleteCount
= 0;
1930 IReferenceClock_GetTime(This
->refClock
, &This
->start_time
);
1931 This
->start_time
+= 500000;
1933 else This
->position
= This
->start_time
= 0;
1935 SendFilterMessage(iface
, SendRun
, 0);
1936 This
->state
= State_Running
;
1937 LeaveCriticalSection(&This
->cs
);
1941 static HRESULT WINAPI
MediaControl_Pause(IMediaControl
*iface
) {
1942 ICOM_THIS_MULTI(IFilterGraphImpl
, IMediaControl_vtbl
, iface
);
1943 TRACE("(%p/%p)->()\n", This
, iface
);
1945 if (This
->state
== State_Paused
) return S_OK
;
1947 EnterCriticalSection(&This
->cs
);
1948 if (This
->state
== State_Stopped
)
1949 This
->EcCompleteCount
= 0;
1951 if (This
->state
== State_Running
&& This
->refClock
)
1953 LONGLONG time
= This
->start_time
;
1954 IReferenceClock_GetTime(This
->refClock
, &time
);
1955 This
->position
+= time
- This
->start_time
;
1958 SendFilterMessage(iface
, SendPause
, 0);
1959 This
->state
= State_Paused
;
1960 LeaveCriticalSection(&This
->cs
);
1964 static HRESULT WINAPI
MediaControl_Stop(IMediaControl
*iface
) {
1965 ICOM_THIS_MULTI(IFilterGraphImpl
, IMediaControl_vtbl
, iface
);
1966 TRACE("(%p/%p)->()\n", This
, iface
);
1968 if (This
->state
== State_Stopped
) return S_OK
;
1970 EnterCriticalSection(&This
->cs
);
1971 if (This
->state
== State_Running
&& This
->refClock
)
1973 LONGLONG time
= This
->start_time
;
1974 IReferenceClock_GetTime(This
->refClock
, &time
);
1975 This
->position
+= time
- This
->start_time
;
1978 if (This
->state
== State_Running
) SendFilterMessage(iface
, SendPause
, 0);
1979 SendFilterMessage(iface
, SendStop
, 0);
1980 This
->state
= State_Stopped
;
1981 LeaveCriticalSection(&This
->cs
);
1985 static HRESULT WINAPI
MediaControl_GetState(IMediaControl
*iface
,
1987 OAFilterState
*pfs
) {
1988 ICOM_THIS_MULTI(IFilterGraphImpl
, IMediaControl_vtbl
, iface
);
1991 TRACE("(%p/%p)->(%d, %p)\n", This
, iface
, msTimeout
, pfs
);
1996 EnterCriticalSection(&This
->cs
);
2001 end
= GetTickCount() + msTimeout
;
2003 else if (msTimeout
< 0)
2012 SendFilterMessage(iface
, SendGetState
, end
);
2014 LeaveCriticalSection(&This
->cs
);
2019 static HRESULT WINAPI
MediaControl_RenderFile(IMediaControl
*iface
,
2021 ICOM_THIS_MULTI(IFilterGraphImpl
, IMediaControl_vtbl
, iface
);
2023 FIXME("(%p/%p)->(%s (%p)): stub !!!\n", This
, iface
, debugstr_w(strFilename
), strFilename
);
2028 static HRESULT WINAPI
MediaControl_AddSourceFilter(IMediaControl
*iface
,
2030 IDispatch
**ppUnk
) {
2031 ICOM_THIS_MULTI(IFilterGraphImpl
, IMediaControl_vtbl
, iface
);
2033 FIXME("(%p/%p)->(%s (%p), %p): stub !!!\n", This
, iface
, debugstr_w(strFilename
), strFilename
, ppUnk
);
2038 static HRESULT WINAPI
MediaControl_get_FilterCollection(IMediaControl
*iface
,
2039 IDispatch
**ppUnk
) {
2040 ICOM_THIS_MULTI(IFilterGraphImpl
, IMediaControl_vtbl
, iface
);
2042 FIXME("(%p/%p)->(%p): stub !!!\n", This
, iface
, ppUnk
);
2047 static HRESULT WINAPI
MediaControl_get_RegFilterCollection(IMediaControl
*iface
,
2048 IDispatch
**ppUnk
) {
2049 ICOM_THIS_MULTI(IFilterGraphImpl
, IMediaControl_vtbl
, iface
);
2051 FIXME("(%p/%p)->(%p): stub !!!\n", This
, iface
, ppUnk
);
2056 static HRESULT WINAPI
MediaControl_StopWhenReady(IMediaControl
*iface
) {
2057 ICOM_THIS_MULTI(IFilterGraphImpl
, IMediaControl_vtbl
, iface
);
2059 FIXME("(%p/%p)->(): stub !!!\n", This
, iface
);
2065 static const IMediaControlVtbl IMediaControl_VTable
=
2067 MediaControl_QueryInterface
,
2068 MediaControl_AddRef
,
2069 MediaControl_Release
,
2070 MediaControl_GetTypeInfoCount
,
2071 MediaControl_GetTypeInfo
,
2072 MediaControl_GetIDsOfNames
,
2073 MediaControl_Invoke
,
2077 MediaControl_GetState
,
2078 MediaControl_RenderFile
,
2079 MediaControl_AddSourceFilter
,
2080 MediaControl_get_FilterCollection
,
2081 MediaControl_get_RegFilterCollection
,
2082 MediaControl_StopWhenReady
2086 /*** IUnknown methods ***/
2087 static HRESULT WINAPI
MediaSeeking_QueryInterface(IMediaSeeking
*iface
,
2090 ICOM_THIS_MULTI(IFilterGraphImpl
, IMediaSeeking_vtbl
, iface
);
2092 TRACE("(%p/%p)->(%s (%p), %p)\n", This
, iface
, debugstr_guid(riid
), riid
, ppvObj
);
2094 return Filtergraph_QueryInterface(This
, riid
, ppvObj
);
2097 static ULONG WINAPI
MediaSeeking_AddRef(IMediaSeeking
*iface
) {
2098 ICOM_THIS_MULTI(IFilterGraphImpl
, IMediaSeeking_vtbl
, iface
);
2100 TRACE("(%p/%p)->()\n", This
, iface
);
2102 return Filtergraph_AddRef(This
);
2105 static ULONG WINAPI
MediaSeeking_Release(IMediaSeeking
*iface
) {
2106 ICOM_THIS_MULTI(IFilterGraphImpl
, IMediaSeeking_vtbl
, iface
);
2108 TRACE("(%p/%p)->()\n", This
, iface
);
2110 return Filtergraph_Release(This
);
2113 typedef HRESULT (WINAPI
*fnFoundSeek
)(IFilterGraphImpl
*This
, IMediaSeeking
*, DWORD_PTR arg
);
2115 static HRESULT
all_renderers_seek(IFilterGraphImpl
*This
, fnFoundSeek FoundSeek
, DWORD_PTR arg
) {
2116 BOOL allnotimpl
= TRUE
;
2118 IBaseFilter
* pfilter
;
2120 HRESULT hr
, hr_return
= S_OK
;
2125 TRACE("(%p)->(%p %08lx)\n", This
, FoundSeek
, arg
);
2126 /* Send a message to all renderers, they are responsible for broadcasting it further */
2128 for(i
= 0; i
< This
->nFilters
; i
++)
2130 BOOL renderer
= TRUE
;
2131 pfilter
= This
->ppFiltersInGraph
[i
];
2132 hr
= IBaseFilter_EnumPins(pfilter
, &pEnum
);
2135 WARN("Enum pins failed %x\n", hr
);
2138 /* Check if it is a source filter */
2139 while(IEnumPins_Next(pEnum
, 1, &pPin
, &dummy
) == S_OK
)
2141 IPin_QueryDirection(pPin
, &dir
);
2143 if (dir
!= PINDIR_INPUT
)
2149 IEnumPins_Release(pEnum
);
2152 IMediaSeeking
*seek
= NULL
;
2153 IBaseFilter_QueryInterface(pfilter
, &IID_IMediaSeeking
, (void**)&seek
);
2157 hr
= FoundSeek(This
, seek
, arg
);
2159 IMediaSeeking_Release(seek
);
2160 if (hr_return
!= E_NOTIMPL
)
2162 if (hr_return
== S_OK
|| (FAILED(hr
) && hr
!= E_NOTIMPL
&& SUCCEEDED(hr_return
)))
2172 static HRESULT WINAPI
FoundCapabilities(IFilterGraphImpl
*This
, IMediaSeeking
*seek
, DWORD_PTR pcaps
)
2177 hr
= IMediaSeeking_GetCapabilities(seek
, &caps
);
2181 /* Only add common capabilities everything supports */
2182 *(DWORD
*)pcaps
&= caps
;
2187 /*** IMediaSeeking methods ***/
2188 static HRESULT WINAPI
MediaSeeking_GetCapabilities(IMediaSeeking
*iface
,
2189 DWORD
*pCapabilities
) {
2190 ICOM_THIS_MULTI(IFilterGraphImpl
, IMediaSeeking_vtbl
, iface
);
2192 TRACE("(%p/%p)->(%p)\n", This
, iface
, pCapabilities
);
2197 EnterCriticalSection(&This
->cs
);
2198 *pCapabilities
= 0xffffffff;
2200 hr
= all_renderers_seek(This
, FoundCapabilities
, (DWORD_PTR
)pCapabilities
);
2201 LeaveCriticalSection(&This
->cs
);
2206 static HRESULT WINAPI
MediaSeeking_CheckCapabilities(IMediaSeeking
*iface
,
2207 DWORD
*pCapabilities
) {
2208 ICOM_THIS_MULTI(IFilterGraphImpl
, IMediaSeeking_vtbl
, iface
);
2211 TRACE("(%p/%p)->(%p)\n", This
, iface
, pCapabilities
);
2216 EnterCriticalSection(&This
->cs
);
2217 originalcaps
= *pCapabilities
;
2218 hr
= all_renderers_seek(This
, FoundCapabilities
, (DWORD_PTR
)pCapabilities
);
2219 LeaveCriticalSection(&This
->cs
);
2224 if (!*pCapabilities
)
2226 if (*pCapabilities
!= originalcaps
)
2231 static HRESULT WINAPI
MediaSeeking_IsFormatSupported(IMediaSeeking
*iface
,
2232 const GUID
*pFormat
) {
2233 ICOM_THIS_MULTI(IFilterGraphImpl
, IMediaSeeking_vtbl
, iface
);
2238 TRACE("(%p/%p)->(%s)\n", This
, iface
, debugstr_guid(pFormat
));
2240 if (!IsEqualGUID(&TIME_FORMAT_MEDIA_TIME
, pFormat
))
2242 FIXME("Unhandled time format %s\n", debugstr_guid(pFormat
));
2249 static HRESULT WINAPI
MediaSeeking_QueryPreferredFormat(IMediaSeeking
*iface
,
2251 ICOM_THIS_MULTI(IFilterGraphImpl
, IMediaSeeking_vtbl
, iface
);
2256 FIXME("(%p/%p)->(%p): semi-stub !!!\n", This
, iface
, pFormat
);
2257 memcpy(pFormat
, &TIME_FORMAT_MEDIA_TIME
, sizeof(GUID
));
2262 static HRESULT WINAPI
MediaSeeking_GetTimeFormat(IMediaSeeking
*iface
,
2264 ICOM_THIS_MULTI(IFilterGraphImpl
, IMediaSeeking_vtbl
, iface
);
2269 TRACE("(%p/%p)->(%p)\n", This
, iface
, pFormat
);
2270 memcpy(pFormat
, &This
->timeformatseek
, sizeof(GUID
));
2275 static HRESULT WINAPI
MediaSeeking_IsUsingTimeFormat(IMediaSeeking
*iface
,
2276 const GUID
*pFormat
) {
2277 ICOM_THIS_MULTI(IFilterGraphImpl
, IMediaSeeking_vtbl
, iface
);
2279 TRACE("(%p/%p)->(%p)\n", This
, iface
, pFormat
);
2283 if (memcmp(pFormat
, &This
->timeformatseek
, sizeof(GUID
)))
2289 static HRESULT WINAPI
MediaSeeking_SetTimeFormat(IMediaSeeking
*iface
,
2290 const GUID
*pFormat
) {
2291 ICOM_THIS_MULTI(IFilterGraphImpl
, IMediaSeeking_vtbl
, iface
);
2296 TRACE("(%p/%p)->(%s)\n", This
, iface
, debugstr_guid(pFormat
));
2298 if (This
->state
!= State_Stopped
)
2299 return VFW_E_WRONG_STATE
;
2301 if (!IsEqualGUID(&TIME_FORMAT_MEDIA_TIME
, pFormat
))
2303 FIXME("Unhandled time format %s\n", debugstr_guid(pFormat
));
2304 return E_INVALIDARG
;
2310 static HRESULT WINAPI
FoundDuration(IFilterGraphImpl
*This
, IMediaSeeking
*seek
, DWORD_PTR pduration
)
2313 LONGLONG duration
= 0, *pdur
= (LONGLONG
*)pduration
;
2315 hr
= IMediaSeeking_GetDuration(seek
, &duration
);
2319 /* FIXME: Minimum or maximum duration? Assuming minimum */
2320 if (duration
> 0 && *pdur
< duration
)
2326 static HRESULT WINAPI
MediaSeeking_GetDuration(IMediaSeeking
*iface
,
2327 LONGLONG
*pDuration
) {
2328 ICOM_THIS_MULTI(IFilterGraphImpl
, IMediaSeeking_vtbl
, iface
);
2331 TRACE("(%p/%p)->(%p)\n", This
, iface
, pDuration
);
2336 EnterCriticalSection(&This
->cs
);
2338 hr
= all_renderers_seek(This
, FoundDuration
, (DWORD_PTR
)pDuration
);
2339 LeaveCriticalSection(&This
->cs
);
2341 TRACE("--->%08x\n", hr
);
2345 static HRESULT WINAPI
MediaSeeking_GetStopPosition(IMediaSeeking
*iface
,
2347 ICOM_THIS_MULTI(IFilterGraphImpl
, IMediaSeeking_vtbl
, iface
);
2350 TRACE("(%p/%p)->(%p)\n", This
, iface
, pStop
);
2355 EnterCriticalSection(&This
->cs
);
2356 if (This
->stop_position
< 0)
2357 /* Stop position not set, use duration instead */
2358 hr
= IMediaSeeking_GetDuration(iface
, pStop
);
2360 *pStop
= This
->stop_position
;
2362 LeaveCriticalSection(&This
->cs
);
2367 static HRESULT WINAPI
MediaSeeking_GetCurrentPosition(IMediaSeeking
*iface
,
2368 LONGLONG
*pCurrent
) {
2369 ICOM_THIS_MULTI(IFilterGraphImpl
, IMediaSeeking_vtbl
, iface
);
2375 EnterCriticalSection(&This
->cs
);
2376 if (This
->state
== State_Running
&& This
->refClock
)
2378 IReferenceClock_GetTime(This
->refClock
, &time
);
2380 time
+= This
->position
- This
->start_time
;
2381 if (time
< This
->position
)
2382 time
= This
->position
;
2386 *pCurrent
= This
->position
;
2387 LeaveCriticalSection(&This
->cs
);
2389 TRACE("Time: %u.%03u\n", (DWORD
)(*pCurrent
/ 10000000), (DWORD
)((*pCurrent
/ 10000)%1000));
2394 static HRESULT WINAPI
MediaSeeking_ConvertTimeFormat(IMediaSeeking
*iface
,
2396 const GUID
*pTargetFormat
,
2398 const GUID
*pSourceFormat
) {
2399 ICOM_THIS_MULTI(IFilterGraphImpl
, IMediaSeeking_vtbl
, iface
);
2401 FIXME("(%p/%p)->(%p, %p, 0x%s, %p): stub !!!\n", This
, iface
, pTarget
,
2402 pTargetFormat
, wine_dbgstr_longlong(Source
), pSourceFormat
);
2408 LONGLONG
* current
, *stop
;
2409 DWORD curflags
, stopflags
;
2412 static HRESULT WINAPI
found_setposition(IFilterGraphImpl
*This
, IMediaSeeking
*seek
, DWORD_PTR pargs
)
2414 struct pos_args
*args
= (void*)pargs
;
2416 return IMediaSeeking_SetPositions(seek
, args
->current
, args
->curflags
, args
->stop
, args
->stopflags
);
2419 static HRESULT WINAPI
MediaSeeking_SetPositions(IMediaSeeking
*iface
,
2421 DWORD dwCurrentFlags
,
2423 DWORD dwStopFlags
) {
2424 ICOM_THIS_MULTI(IFilterGraphImpl
, IMediaSeeking_vtbl
, iface
);
2427 struct pos_args args
;
2429 TRACE("(%p/%p)->(%p, %08x, %p, %08x)\n", This
, iface
, pCurrent
, dwCurrentFlags
, pStop
, dwStopFlags
);
2431 EnterCriticalSection(&This
->cs
);
2432 state
= This
->state
;
2433 TRACE("State: %s\n", state
== State_Running
? "Running" : (state
== State_Paused
? "Paused" : (state
== State_Stopped
? "Stopped" : "UNKNOWN")));
2435 if ((dwCurrentFlags
& 0x7) == AM_SEEKING_AbsolutePositioning
)
2437 This
->position
= *pCurrent
;
2439 else if ((dwCurrentFlags
& 0x7) != AM_SEEKING_NoPositioning
)
2440 FIXME("Adjust method %x not handled yet!\n", dwCurrentFlags
& 0x7);
2442 if ((dwStopFlags
& 0x7) == AM_SEEKING_AbsolutePositioning
)
2443 This
->stop_position
= *pStop
;
2444 else if ((dwStopFlags
& 0x7) != AM_SEEKING_NoPositioning
)
2445 FIXME("Stop position not handled yet!\n");
2447 args
.current
= pCurrent
;
2449 args
.curflags
= dwCurrentFlags
;
2450 args
.stopflags
= dwStopFlags
;
2451 hr
= all_renderers_seek(This
, found_setposition
, (DWORD_PTR
)&args
);
2453 if (This
->refClock
&& ((dwCurrentFlags
& 0x7) != AM_SEEKING_NoPositioning
))
2455 /* Update start time, prevents weird jumps */
2456 IReferenceClock_GetTime(This
->refClock
, &This
->start_time
);
2458 LeaveCriticalSection(&This
->cs
);
2463 static HRESULT WINAPI
MediaSeeking_GetPositions(IMediaSeeking
*iface
,
2466 ICOM_THIS_MULTI(IFilterGraphImpl
, IMediaSeeking_vtbl
, iface
);
2469 TRACE("(%p/%p)->(%p, %p)\n", This
, iface
, pCurrent
, pStop
);
2470 hr
= IMediaSeeking_GetCurrentPosition(iface
, pCurrent
);
2472 hr
= IMediaSeeking_GetStopPosition(iface
, pStop
);
2477 static HRESULT WINAPI
MediaSeeking_GetAvailable(IMediaSeeking
*iface
,
2478 LONGLONG
*pEarliest
,
2479 LONGLONG
*pLatest
) {
2480 ICOM_THIS_MULTI(IFilterGraphImpl
, IMediaSeeking_vtbl
, iface
);
2482 FIXME("(%p/%p)->(%p, %p): stub !!!\n", This
, iface
, pEarliest
, pLatest
);
2487 static HRESULT WINAPI
MediaSeeking_SetRate(IMediaSeeking
*iface
,
2489 ICOM_THIS_MULTI(IFilterGraphImpl
, IMediaSeeking_vtbl
, iface
);
2491 FIXME("(%p/%p)->(%f): stub !!!\n", This
, iface
, dRate
);
2496 static HRESULT WINAPI
MediaSeeking_GetRate(IMediaSeeking
*iface
,
2498 ICOM_THIS_MULTI(IFilterGraphImpl
, IMediaSeeking_vtbl
, iface
);
2500 FIXME("(%p/%p)->(%p): stub !!!\n", This
, iface
, pdRate
);
2505 static HRESULT WINAPI
MediaSeeking_GetPreroll(IMediaSeeking
*iface
,
2506 LONGLONG
*pllPreroll
) {
2507 ICOM_THIS_MULTI(IFilterGraphImpl
, IMediaSeeking_vtbl
, iface
);
2509 FIXME("(%p/%p)->(%p): stub !!!\n", This
, iface
, pllPreroll
);
2515 static const IMediaSeekingVtbl IMediaSeeking_VTable
=
2517 MediaSeeking_QueryInterface
,
2518 MediaSeeking_AddRef
,
2519 MediaSeeking_Release
,
2520 MediaSeeking_GetCapabilities
,
2521 MediaSeeking_CheckCapabilities
,
2522 MediaSeeking_IsFormatSupported
,
2523 MediaSeeking_QueryPreferredFormat
,
2524 MediaSeeking_GetTimeFormat
,
2525 MediaSeeking_IsUsingTimeFormat
,
2526 MediaSeeking_SetTimeFormat
,
2527 MediaSeeking_GetDuration
,
2528 MediaSeeking_GetStopPosition
,
2529 MediaSeeking_GetCurrentPosition
,
2530 MediaSeeking_ConvertTimeFormat
,
2531 MediaSeeking_SetPositions
,
2532 MediaSeeking_GetPositions
,
2533 MediaSeeking_GetAvailable
,
2534 MediaSeeking_SetRate
,
2535 MediaSeeking_GetRate
,
2536 MediaSeeking_GetPreroll
2539 /*** IUnknown methods ***/
2540 static HRESULT WINAPI
MediaPosition_QueryInterface(IMediaPosition
* iface
, REFIID riid
, void** ppvObj
){
2541 ICOM_THIS_MULTI(IFilterGraphImpl
, IMediaPosition_vtbl
, iface
);
2543 TRACE("(%p/%p)->(%s (%p), %p)\n", This
, iface
, debugstr_guid(riid
), riid
, ppvObj
);
2545 return Filtergraph_QueryInterface(This
, riid
, ppvObj
);
2548 static ULONG WINAPI
MediaPosition_AddRef(IMediaPosition
*iface
){
2549 ICOM_THIS_MULTI(IFilterGraphImpl
, IMediaPosition_vtbl
, iface
);
2551 TRACE("(%p/%p)->()\n", This
, iface
);
2553 return Filtergraph_AddRef(This
);
2556 static ULONG WINAPI
MediaPosition_Release(IMediaPosition
*iface
){
2557 ICOM_THIS_MULTI(IFilterGraphImpl
, IMediaPosition_vtbl
, iface
);
2559 TRACE("(%p/%p)->()\n", This
, iface
);
2561 return Filtergraph_Release(This
);
2564 /*** IDispatch methods ***/
2565 static HRESULT WINAPI
MediaPosition_GetTypeInfoCount(IMediaPosition
*iface
, UINT
* pctinfo
){
2566 FIXME("(%p) stub!\n", iface
);
2570 static HRESULT WINAPI
MediaPosition_GetTypeInfo(IMediaPosition
*iface
, UINT iTInfo
, LCID lcid
, ITypeInfo
** ppTInfo
){
2571 FIXME("(%p) stub!\n", iface
);
2575 static HRESULT WINAPI
MediaPosition_GetIDsOfNames(IMediaPosition
* iface
, REFIID riid
, LPOLESTR
* rgszNames
, UINT cNames
, LCID lcid
, DISPID
* rgDispId
){
2576 FIXME("(%p) stub!\n", iface
);
2580 static HRESULT WINAPI
MediaPosition_Invoke(IMediaPosition
* iface
, DISPID dispIdMember
, REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
* pDispParams
, VARIANT
* pVarResult
, EXCEPINFO
* pExcepInfo
, UINT
* puArgErr
){
2581 FIXME("(%p) stub!\n", iface
);
2585 /*** IMediaPosition methods ***/
2586 static HRESULT WINAPI
MediaPosition_get_Duration(IMediaPosition
* iface
, REFTIME
*plength
){
2587 FIXME("(%p)->(%p) stub!\n", iface
, plength
);
2591 static HRESULT WINAPI
MediaPosition_put_CurrentPosition(IMediaPosition
* iface
, REFTIME llTime
){
2592 ICOM_THIS_MULTI(IFilterGraphImpl
, IMediaPosition_vtbl
, iface
);
2593 LONGLONG reftime
= llTime
;
2595 return IMediaSeeking_SetPositions((IMediaSeeking
*)&This
->IMediaSeeking_vtbl
, &reftime
, AM_SEEKING_AbsolutePositioning
, NULL
, AM_SEEKING_NoPositioning
);
2598 static HRESULT WINAPI
MediaPosition_get_CurrentPosition(IMediaPosition
* iface
, REFTIME
*pllTime
){
2599 FIXME("(%p)->(%p) stub!\n", iface
, pllTime
);
2603 static HRESULT WINAPI
MediaPosition_get_StopTime(IMediaPosition
* iface
, REFTIME
*pllTime
){
2604 FIXME("(%p)->(%p) stub!\n", iface
, pllTime
);
2608 static HRESULT WINAPI
MediaPosition_put_StopTime(IMediaPosition
* iface
, REFTIME llTime
){
2609 FIXME("(%p)->(%f) stub!\n", iface
, llTime
);
2613 static HRESULT WINAPI
MediaPosition_get_PrerollTime(IMediaPosition
* iface
, REFTIME
*pllTime
){
2614 FIXME("(%p)->(%p) stub!\n", iface
, pllTime
);
2618 static HRESULT WINAPI
MediaPosition_put_PrerollTime(IMediaPosition
* iface
, REFTIME llTime
){
2619 FIXME("(%p)->(%f) stub!\n", iface
, llTime
);
2623 static HRESULT WINAPI
MediaPosition_put_Rate(IMediaPosition
* iface
, double dRate
){
2624 FIXME("(%p)->(%f) stub!\n", iface
, dRate
);
2628 static HRESULT WINAPI
MediaPosition_get_Rate(IMediaPosition
* iface
, double *pdRate
){
2629 FIXME("(%p)->(%p) stub!\n", iface
, pdRate
);
2633 static HRESULT WINAPI
MediaPosition_CanSeekForward(IMediaPosition
* iface
, LONG
*pCanSeekForward
){
2634 FIXME("(%p)->(%p) stub!\n", iface
, pCanSeekForward
);
2638 static HRESULT WINAPI
MediaPosition_CanSeekBackward(IMediaPosition
* iface
, LONG
*pCanSeekBackward
){
2639 FIXME("(%p)->(%p) stub!\n", iface
, pCanSeekBackward
);
2644 static const IMediaPositionVtbl IMediaPosition_VTable
=
2646 MediaPosition_QueryInterface
,
2647 MediaPosition_AddRef
,
2648 MediaPosition_Release
,
2649 MediaPosition_GetTypeInfoCount
,
2650 MediaPosition_GetTypeInfo
,
2651 MediaPosition_GetIDsOfNames
,
2652 MediaPosition_Invoke
,
2653 MediaPosition_get_Duration
,
2654 MediaPosition_put_CurrentPosition
,
2655 MediaPosition_get_CurrentPosition
,
2656 MediaPosition_get_StopTime
,
2657 MediaPosition_put_StopTime
,
2658 MediaPosition_get_PrerollTime
,
2659 MediaPosition_put_PrerollTime
,
2660 MediaPosition_put_Rate
,
2661 MediaPosition_get_Rate
,
2662 MediaPosition_CanSeekForward
,
2663 MediaPosition_CanSeekBackward
2666 static HRESULT
GetTargetInterface(IFilterGraphImpl
* pGraph
, REFIID riid
, LPVOID
* ppvObj
)
2668 HRESULT hr
= E_NOINTERFACE
;
2672 /* Check if the interface type is already registered */
2673 for (entry
= 0; entry
< pGraph
->nItfCacheEntries
; entry
++)
2674 if (riid
== pGraph
->ItfCacheEntries
[entry
].riid
)
2676 if (pGraph
->ItfCacheEntries
[entry
].iface
)
2678 /* Return the interface if available */
2679 *ppvObj
= pGraph
->ItfCacheEntries
[entry
].iface
;
2685 if (entry
>= MAX_ITF_CACHE_ENTRIES
)
2687 FIXME("Not enough space to store interface in the cache\n");
2688 return E_OUTOFMEMORY
;
2691 /* Find a filter supporting the requested interface */
2692 for (i
= 0; i
< pGraph
->nFilters
; i
++)
2694 hr
= IBaseFilter_QueryInterface(pGraph
->ppFiltersInGraph
[i
], riid
, ppvObj
);
2697 pGraph
->ItfCacheEntries
[entry
].riid
= riid
;
2698 pGraph
->ItfCacheEntries
[entry
].filter
= pGraph
->ppFiltersInGraph
[i
];
2699 pGraph
->ItfCacheEntries
[entry
].iface
= (IUnknown
*)*ppvObj
;
2700 if (entry
>= pGraph
->nItfCacheEntries
)
2701 pGraph
->nItfCacheEntries
++;
2704 if (hr
!= E_NOINTERFACE
)
2711 /*** IUnknown methods ***/
2712 static HRESULT WINAPI
BasicAudio_QueryInterface(IBasicAudio
*iface
,
2715 ICOM_THIS_MULTI(IFilterGraphImpl
, IBasicAudio_vtbl
, iface
);
2717 TRACE("(%p/%p)->(%s (%p), %p)\n", This
, iface
, debugstr_guid(riid
), riid
, ppvObj
);
2719 return Filtergraph_QueryInterface(This
, riid
, ppvObj
);
2722 static ULONG WINAPI
BasicAudio_AddRef(IBasicAudio
*iface
) {
2723 ICOM_THIS_MULTI(IFilterGraphImpl
, IBasicAudio_vtbl
, iface
);
2725 TRACE("(%p/%p)->()\n", This
, iface
);
2727 return Filtergraph_AddRef(This
);
2730 static ULONG WINAPI
BasicAudio_Release(IBasicAudio
*iface
) {
2731 ICOM_THIS_MULTI(IFilterGraphImpl
, IBasicAudio_vtbl
, iface
);
2733 TRACE("(%p/%p)->()\n", This
, iface
);
2735 return Filtergraph_Release(This
);
2738 /*** IDispatch methods ***/
2739 static HRESULT WINAPI
BasicAudio_GetTypeInfoCount(IBasicAudio
*iface
,
2741 ICOM_THIS_MULTI(IFilterGraphImpl
, IBasicAudio_vtbl
, iface
);
2742 IBasicAudio
* pBasicAudio
;
2745 TRACE("(%p/%p)->(%p)\n", This
, iface
, pctinfo
);
2747 EnterCriticalSection(&This
->cs
);
2749 hr
= GetTargetInterface(This
, &IID_IBasicAudio
, (LPVOID
*)&pBasicAudio
);
2752 hr
= IBasicAudio_GetTypeInfoCount(pBasicAudio
, pctinfo
);
2754 LeaveCriticalSection(&This
->cs
);
2759 static HRESULT WINAPI
BasicAudio_GetTypeInfo(IBasicAudio
*iface
,
2762 ITypeInfo
**ppTInfo
) {
2763 ICOM_THIS_MULTI(IFilterGraphImpl
, IBasicAudio_vtbl
, iface
);
2764 IBasicAudio
* pBasicAudio
;
2767 TRACE("(%p/%p)->(%d, %d, %p)\n", This
, iface
, iTInfo
, lcid
, ppTInfo
);
2769 EnterCriticalSection(&This
->cs
);
2771 hr
= GetTargetInterface(This
, &IID_IBasicAudio
, (LPVOID
*)&pBasicAudio
);
2774 hr
= IBasicAudio_GetTypeInfo(pBasicAudio
, iTInfo
, lcid
, ppTInfo
);
2776 LeaveCriticalSection(&This
->cs
);
2781 static HRESULT WINAPI
BasicAudio_GetIDsOfNames(IBasicAudio
*iface
,
2787 ICOM_THIS_MULTI(IFilterGraphImpl
, IBasicAudio_vtbl
, iface
);
2788 IBasicAudio
* pBasicAudio
;
2791 TRACE("(%p/%p)->(%s (%p), %p, %d, %d, %p)\n", This
, iface
, debugstr_guid(riid
), riid
, rgszNames
, cNames
, lcid
, rgDispId
);
2793 EnterCriticalSection(&This
->cs
);
2795 hr
= GetTargetInterface(This
, &IID_IBasicAudio
, (LPVOID
*)&pBasicAudio
);
2798 hr
= IBasicAudio_GetIDsOfNames(pBasicAudio
, riid
, rgszNames
, cNames
, lcid
, rgDispId
);
2800 LeaveCriticalSection(&This
->cs
);
2805 static HRESULT WINAPI
BasicAudio_Invoke(IBasicAudio
*iface
,
2806 DISPID dispIdMember
,
2810 DISPPARAMS
*pDispParams
,
2812 EXCEPINFO
*pExepInfo
,
2814 ICOM_THIS_MULTI(IFilterGraphImpl
, IBasicAudio_vtbl
, iface
);
2815 IBasicAudio
* pBasicAudio
;
2818 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
);
2820 EnterCriticalSection(&This
->cs
);
2822 hr
= GetTargetInterface(This
, &IID_IBasicAudio
, (LPVOID
*)&pBasicAudio
);
2825 hr
= IBasicAudio_Invoke(pBasicAudio
, dispIdMember
, riid
, lcid
, wFlags
, pDispParams
, pVarResult
, pExepInfo
, puArgErr
);
2827 LeaveCriticalSection(&This
->cs
);
2832 /*** IBasicAudio methods ***/
2833 static HRESULT WINAPI
BasicAudio_put_Volume(IBasicAudio
*iface
,
2835 ICOM_THIS_MULTI(IFilterGraphImpl
, IBasicAudio_vtbl
, iface
);
2836 IBasicAudio
* pBasicAudio
;
2839 TRACE("(%p/%p)->(%ld)\n", This
, iface
, lVolume
);
2841 EnterCriticalSection(&This
->cs
);
2843 hr
= GetTargetInterface(This
, &IID_IBasicAudio
, (LPVOID
*)&pBasicAudio
);
2846 hr
= IBasicAudio_put_Volume(pBasicAudio
, lVolume
);
2848 LeaveCriticalSection(&This
->cs
);
2853 static HRESULT WINAPI
BasicAudio_get_Volume(IBasicAudio
*iface
,
2855 ICOM_THIS_MULTI(IFilterGraphImpl
, IBasicAudio_vtbl
, iface
);
2856 IBasicAudio
* pBasicAudio
;
2859 TRACE("(%p/%p)->(%p)\n", This
, iface
, plVolume
);
2861 EnterCriticalSection(&This
->cs
);
2863 hr
= GetTargetInterface(This
, &IID_IBasicAudio
, (LPVOID
*)&pBasicAudio
);
2866 hr
= IBasicAudio_get_Volume(pBasicAudio
, plVolume
);
2868 LeaveCriticalSection(&This
->cs
);
2873 static HRESULT WINAPI
BasicAudio_put_Balance(IBasicAudio
*iface
,
2875 ICOM_THIS_MULTI(IFilterGraphImpl
, IBasicAudio_vtbl
, iface
);
2876 IBasicAudio
* pBasicAudio
;
2879 TRACE("(%p/%p)->(%ld)\n", This
, iface
, lBalance
);
2881 EnterCriticalSection(&This
->cs
);
2883 hr
= GetTargetInterface(This
, &IID_IBasicAudio
, (LPVOID
*)&pBasicAudio
);
2886 hr
= IBasicAudio_put_Balance(pBasicAudio
, lBalance
);
2888 LeaveCriticalSection(&This
->cs
);
2893 static HRESULT WINAPI
BasicAudio_get_Balance(IBasicAudio
*iface
,
2895 ICOM_THIS_MULTI(IFilterGraphImpl
, IBasicAudio_vtbl
, iface
);
2896 IBasicAudio
* pBasicAudio
;
2899 TRACE("(%p/%p)->(%p)\n", This
, iface
, plBalance
);
2901 EnterCriticalSection(&This
->cs
);
2903 hr
= GetTargetInterface(This
, &IID_IBasicAudio
, (LPVOID
*)&pBasicAudio
);
2906 hr
= IBasicAudio_get_Balance(pBasicAudio
, plBalance
);
2908 LeaveCriticalSection(&This
->cs
);
2913 static const IBasicAudioVtbl IBasicAudio_VTable
=
2915 BasicAudio_QueryInterface
,
2918 BasicAudio_GetTypeInfoCount
,
2919 BasicAudio_GetTypeInfo
,
2920 BasicAudio_GetIDsOfNames
,
2922 BasicAudio_put_Volume
,
2923 BasicAudio_get_Volume
,
2924 BasicAudio_put_Balance
,
2925 BasicAudio_get_Balance
2928 /*** IUnknown methods ***/
2929 static HRESULT WINAPI
BasicVideo_QueryInterface(IBasicVideo2
*iface
,
2932 ICOM_THIS_MULTI(IFilterGraphImpl
, IBasicVideo_vtbl
, iface
);
2934 TRACE("(%p/%p)->(%s (%p), %p)\n", This
, iface
, debugstr_guid(riid
), riid
, ppvObj
);
2936 return Filtergraph_QueryInterface(This
, riid
, ppvObj
);
2939 static ULONG WINAPI
BasicVideo_AddRef(IBasicVideo2
*iface
) {
2940 ICOM_THIS_MULTI(IFilterGraphImpl
, IBasicVideo_vtbl
, iface
);
2942 TRACE("(%p/%p)->()\n", This
, iface
);
2944 return Filtergraph_AddRef(This
);
2947 static ULONG WINAPI
BasicVideo_Release(IBasicVideo2
*iface
) {
2948 ICOM_THIS_MULTI(IFilterGraphImpl
, IBasicVideo_vtbl
, iface
);
2950 TRACE("(%p/%p)->()\n", This
, iface
);
2952 return Filtergraph_Release(This
);
2955 /*** IDispatch methods ***/
2956 static HRESULT WINAPI
BasicVideo_GetTypeInfoCount(IBasicVideo2
*iface
,
2958 ICOM_THIS_MULTI(IFilterGraphImpl
, IBasicVideo_vtbl
, iface
);
2959 IBasicVideo
* pBasicVideo
;
2962 TRACE("(%p/%p)->(%p)\n", This
, iface
, pctinfo
);
2964 EnterCriticalSection(&This
->cs
);
2966 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
2969 hr
= IBasicVideo_GetTypeInfoCount(pBasicVideo
, pctinfo
);
2971 LeaveCriticalSection(&This
->cs
);
2976 static HRESULT WINAPI
BasicVideo_GetTypeInfo(IBasicVideo2
*iface
,
2979 ITypeInfo
**ppTInfo
) {
2980 ICOM_THIS_MULTI(IFilterGraphImpl
, IBasicVideo_vtbl
, iface
);
2981 IBasicVideo
* pBasicVideo
;
2984 TRACE("(%p/%p)->(%d, %d, %p)\n", This
, iface
, iTInfo
, lcid
, ppTInfo
);
2986 EnterCriticalSection(&This
->cs
);
2988 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
2991 hr
= IBasicVideo_GetTypeInfo(pBasicVideo
, iTInfo
, lcid
, ppTInfo
);
2993 LeaveCriticalSection(&This
->cs
);
2998 static HRESULT WINAPI
BasicVideo_GetIDsOfNames(IBasicVideo2
*iface
,
3004 ICOM_THIS_MULTI(IFilterGraphImpl
, IBasicVideo_vtbl
, iface
);
3005 IBasicVideo
* pBasicVideo
;
3008 TRACE("(%p/%p)->(%s (%p), %p, %d, %d, %p)\n", This
, iface
, debugstr_guid(riid
), riid
, rgszNames
, cNames
, lcid
, rgDispId
);
3010 EnterCriticalSection(&This
->cs
);
3012 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3015 hr
= IBasicVideo_GetIDsOfNames(pBasicVideo
, riid
, rgszNames
, cNames
, lcid
, rgDispId
);
3017 LeaveCriticalSection(&This
->cs
);
3022 static HRESULT WINAPI
BasicVideo_Invoke(IBasicVideo2
*iface
,
3023 DISPID dispIdMember
,
3027 DISPPARAMS
*pDispParams
,
3029 EXCEPINFO
*pExepInfo
,
3031 ICOM_THIS_MULTI(IFilterGraphImpl
, IBasicVideo_vtbl
, iface
);
3032 IBasicVideo
* pBasicVideo
;
3035 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
);
3037 EnterCriticalSection(&This
->cs
);
3039 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3042 hr
= IBasicVideo_Invoke(pBasicVideo
, dispIdMember
, riid
, lcid
, wFlags
, pDispParams
, pVarResult
, pExepInfo
, puArgErr
);
3044 LeaveCriticalSection(&This
->cs
);
3049 /*** IBasicVideo methods ***/
3050 static HRESULT WINAPI
BasicVideo_get_AvgTimePerFrame(IBasicVideo2
*iface
,
3051 REFTIME
*pAvgTimePerFrame
) {
3052 ICOM_THIS_MULTI(IFilterGraphImpl
, IBasicVideo_vtbl
, iface
);
3053 IBasicVideo
* pBasicVideo
;
3056 TRACE("(%p/%p)->(%p)\n", This
, iface
, pAvgTimePerFrame
);
3058 EnterCriticalSection(&This
->cs
);
3060 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3063 hr
= IBasicVideo_get_AvgTimePerFrame(pBasicVideo
, pAvgTimePerFrame
);
3065 LeaveCriticalSection(&This
->cs
);
3070 static HRESULT WINAPI
BasicVideo_get_BitRate(IBasicVideo2
*iface
,
3072 ICOM_THIS_MULTI(IFilterGraphImpl
, IBasicVideo_vtbl
, iface
);
3073 IBasicVideo
* pBasicVideo
;
3076 TRACE("(%p/%p)->(%p)\n", This
, iface
, pBitRate
);
3078 EnterCriticalSection(&This
->cs
);
3080 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3083 hr
= IBasicVideo_get_BitRate(pBasicVideo
, pBitRate
);
3085 LeaveCriticalSection(&This
->cs
);
3090 static HRESULT WINAPI
BasicVideo_get_BitErrorRate(IBasicVideo2
*iface
,
3091 long *pBitErrorRate
) {
3092 ICOM_THIS_MULTI(IFilterGraphImpl
, IBasicVideo_vtbl
, iface
);
3093 IBasicVideo
* pBasicVideo
;
3096 TRACE("(%p/%p)->(%p)\n", This
, iface
, pBitErrorRate
);
3098 EnterCriticalSection(&This
->cs
);
3100 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3103 hr
= IBasicVideo_get_BitErrorRate(pBasicVideo
, pBitErrorRate
);
3105 LeaveCriticalSection(&This
->cs
);
3110 static HRESULT WINAPI
BasicVideo_get_VideoWidth(IBasicVideo2
*iface
,
3111 long *pVideoWidth
) {
3112 ICOM_THIS_MULTI(IFilterGraphImpl
, IBasicVideo_vtbl
, iface
);
3113 IBasicVideo
* pBasicVideo
;
3116 TRACE("(%p/%p)->(%p)\n", This
, iface
, pVideoWidth
);
3118 EnterCriticalSection(&This
->cs
);
3120 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3123 hr
= IBasicVideo_get_VideoWidth(pBasicVideo
, pVideoWidth
);
3125 LeaveCriticalSection(&This
->cs
);
3130 static HRESULT WINAPI
BasicVideo_get_VideoHeight(IBasicVideo2
*iface
,
3131 long *pVideoHeight
) {
3132 ICOM_THIS_MULTI(IFilterGraphImpl
, IBasicVideo_vtbl
, iface
);
3133 IBasicVideo
* pBasicVideo
;
3136 TRACE("(%p/%p)->(%p)\n", This
, iface
, pVideoHeight
);
3138 EnterCriticalSection(&This
->cs
);
3140 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3143 hr
= IBasicVideo_get_VideoHeight(pBasicVideo
, pVideoHeight
);
3145 LeaveCriticalSection(&This
->cs
);
3150 static HRESULT WINAPI
BasicVideo_put_SourceLeft(IBasicVideo2
*iface
,
3152 ICOM_THIS_MULTI(IFilterGraphImpl
, IBasicVideo_vtbl
, iface
);
3153 IBasicVideo
* pBasicVideo
;
3156 TRACE("(%p/%p)->(%ld)\n", This
, iface
, SourceLeft
);
3158 EnterCriticalSection(&This
->cs
);
3160 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3163 hr
= IBasicVideo_put_SourceLeft(pBasicVideo
, SourceLeft
);
3165 LeaveCriticalSection(&This
->cs
);
3170 static HRESULT WINAPI
BasicVideo_get_SourceLeft(IBasicVideo2
*iface
,
3171 long *pSourceLeft
) {
3172 ICOM_THIS_MULTI(IFilterGraphImpl
, IBasicVideo_vtbl
, iface
);
3173 IBasicVideo
* pBasicVideo
;
3176 TRACE("(%p/%p)->(%p)\n", This
, iface
, pSourceLeft
);
3178 EnterCriticalSection(&This
->cs
);
3180 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3183 hr
= IBasicVideo_get_SourceLeft(pBasicVideo
, pSourceLeft
);
3185 LeaveCriticalSection(&This
->cs
);
3190 static HRESULT WINAPI
BasicVideo_put_SourceWidth(IBasicVideo2
*iface
,
3192 ICOM_THIS_MULTI(IFilterGraphImpl
, IBasicVideo_vtbl
, iface
);
3193 IBasicVideo
* pBasicVideo
;
3196 TRACE("(%p/%p)->(%ld)\n", This
, iface
, SourceWidth
);
3198 EnterCriticalSection(&This
->cs
);
3200 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3203 hr
= IBasicVideo_put_SourceWidth(pBasicVideo
, SourceWidth
);
3205 LeaveCriticalSection(&This
->cs
);
3210 static HRESULT WINAPI
BasicVideo_get_SourceWidth(IBasicVideo2
*iface
,
3211 long *pSourceWidth
) {
3212 ICOM_THIS_MULTI(IFilterGraphImpl
, IBasicVideo_vtbl
, iface
);
3213 IBasicVideo
* pBasicVideo
;
3216 TRACE("(%p/%p)->(%p)\n", This
, iface
, pSourceWidth
);
3218 EnterCriticalSection(&This
->cs
);
3220 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3223 hr
= IBasicVideo_get_SourceWidth(pBasicVideo
, pSourceWidth
);
3225 LeaveCriticalSection(&This
->cs
);
3230 static HRESULT WINAPI
BasicVideo_put_SourceTop(IBasicVideo2
*iface
,
3232 ICOM_THIS_MULTI(IFilterGraphImpl
, IBasicVideo_vtbl
, iface
);
3233 IBasicVideo
* pBasicVideo
;
3236 TRACE("(%p/%p)->(%ld)\n", This
, iface
, SourceTop
);
3238 EnterCriticalSection(&This
->cs
);
3240 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3243 hr
= IBasicVideo_put_SourceTop(pBasicVideo
, SourceTop
);
3245 LeaveCriticalSection(&This
->cs
);
3250 static HRESULT WINAPI
BasicVideo_get_SourceTop(IBasicVideo2
*iface
,
3252 ICOM_THIS_MULTI(IFilterGraphImpl
, IBasicVideo_vtbl
, iface
);
3253 IBasicVideo
* pBasicVideo
;
3256 TRACE("(%p/%p)->(%p)\n", This
, iface
, pSourceTop
);
3258 EnterCriticalSection(&This
->cs
);
3260 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3263 hr
= IBasicVideo_get_SourceTop(pBasicVideo
, pSourceTop
);
3265 LeaveCriticalSection(&This
->cs
);
3270 static HRESULT WINAPI
BasicVideo_put_SourceHeight(IBasicVideo2
*iface
,
3271 long SourceHeight
) {
3272 ICOM_THIS_MULTI(IFilterGraphImpl
, IBasicVideo_vtbl
, iface
);
3273 IBasicVideo
* pBasicVideo
;
3276 TRACE("(%p/%p)->(%ld)\n", This
, iface
, SourceHeight
);
3278 EnterCriticalSection(&This
->cs
);
3280 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3283 hr
= IBasicVideo_put_SourceHeight(pBasicVideo
, SourceHeight
);
3285 LeaveCriticalSection(&This
->cs
);
3290 static HRESULT WINAPI
BasicVideo_get_SourceHeight(IBasicVideo2
*iface
,
3291 long *pSourceHeight
) {
3292 ICOM_THIS_MULTI(IFilterGraphImpl
, IBasicVideo_vtbl
, iface
);
3293 IBasicVideo
* pBasicVideo
;
3296 TRACE("(%p/%p)->(%p)\n", This
, iface
, pSourceHeight
);
3298 EnterCriticalSection(&This
->cs
);
3300 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3303 hr
= IBasicVideo_get_SourceHeight(pBasicVideo
, pSourceHeight
);
3305 LeaveCriticalSection(&This
->cs
);
3310 static HRESULT WINAPI
BasicVideo_put_DestinationLeft(IBasicVideo2
*iface
,
3311 long DestinationLeft
) {
3312 ICOM_THIS_MULTI(IFilterGraphImpl
, IBasicVideo_vtbl
, iface
);
3313 IBasicVideo
* pBasicVideo
;
3316 TRACE("(%p/%p)->(%ld)\n", This
, iface
, DestinationLeft
);
3318 EnterCriticalSection(&This
->cs
);
3320 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3323 hr
= IBasicVideo_put_DestinationLeft(pBasicVideo
, DestinationLeft
);
3325 LeaveCriticalSection(&This
->cs
);
3330 static HRESULT WINAPI
BasicVideo_get_DestinationLeft(IBasicVideo2
*iface
,
3331 long *pDestinationLeft
) {
3332 ICOM_THIS_MULTI(IFilterGraphImpl
, IBasicVideo_vtbl
, iface
);
3333 IBasicVideo
* pBasicVideo
;
3336 TRACE("(%p/%p)->(%p)\n", This
, iface
, pDestinationLeft
);
3338 EnterCriticalSection(&This
->cs
);
3340 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3343 hr
= IBasicVideo_get_DestinationLeft(pBasicVideo
, pDestinationLeft
);
3345 LeaveCriticalSection(&This
->cs
);
3350 static HRESULT WINAPI
BasicVideo_put_DestinationWidth(IBasicVideo2
*iface
,
3351 long DestinationWidth
) {
3352 ICOM_THIS_MULTI(IFilterGraphImpl
, IBasicVideo_vtbl
, iface
);
3353 IBasicVideo
* pBasicVideo
;
3356 TRACE("(%p/%p)->(%ld)\n", This
, iface
, DestinationWidth
);
3358 EnterCriticalSection(&This
->cs
);
3360 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3363 hr
= IBasicVideo_put_DestinationWidth(pBasicVideo
, DestinationWidth
);
3365 LeaveCriticalSection(&This
->cs
);
3370 static HRESULT WINAPI
BasicVideo_get_DestinationWidth(IBasicVideo2
*iface
,
3371 long *pDestinationWidth
) {
3372 ICOM_THIS_MULTI(IFilterGraphImpl
, IBasicVideo_vtbl
, iface
);
3373 IBasicVideo
* pBasicVideo
;
3376 TRACE("(%p/%p)->(%p)\n", This
, iface
, pDestinationWidth
);
3378 EnterCriticalSection(&This
->cs
);
3380 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3383 hr
= IBasicVideo_get_DestinationWidth(pBasicVideo
, pDestinationWidth
);
3385 LeaveCriticalSection(&This
->cs
);
3390 static HRESULT WINAPI
BasicVideo_put_DestinationTop(IBasicVideo2
*iface
,
3391 long DestinationTop
) {
3392 ICOM_THIS_MULTI(IFilterGraphImpl
, IBasicVideo_vtbl
, iface
);
3393 IBasicVideo
* pBasicVideo
;
3396 TRACE("(%p/%p)->(%ld)\n", This
, iface
, DestinationTop
);
3398 EnterCriticalSection(&This
->cs
);
3400 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3403 hr
= IBasicVideo_put_DestinationTop(pBasicVideo
, DestinationTop
);
3405 LeaveCriticalSection(&This
->cs
);
3410 static HRESULT WINAPI
BasicVideo_get_DestinationTop(IBasicVideo2
*iface
,
3411 long *pDestinationTop
) {
3412 ICOM_THIS_MULTI(IFilterGraphImpl
, IBasicVideo_vtbl
, iface
);
3413 IBasicVideo
* pBasicVideo
;
3416 TRACE("(%p/%p)->(%p)\n", This
, iface
, pDestinationTop
);
3418 EnterCriticalSection(&This
->cs
);
3420 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3423 hr
= IBasicVideo_get_DestinationTop(pBasicVideo
, pDestinationTop
);
3425 LeaveCriticalSection(&This
->cs
);
3430 static HRESULT WINAPI
BasicVideo_put_DestinationHeight(IBasicVideo2
*iface
,
3431 long DestinationHeight
) {
3432 ICOM_THIS_MULTI(IFilterGraphImpl
, IBasicVideo_vtbl
, iface
);
3433 IBasicVideo
* pBasicVideo
;
3436 TRACE("(%p/%p)->(%ld)\n", This
, iface
, DestinationHeight
);
3438 EnterCriticalSection(&This
->cs
);
3440 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3443 hr
= IBasicVideo_put_DestinationHeight(pBasicVideo
, DestinationHeight
);
3445 LeaveCriticalSection(&This
->cs
);
3450 static HRESULT WINAPI
BasicVideo_get_DestinationHeight(IBasicVideo2
*iface
,
3451 long *pDestinationHeight
) {
3452 ICOM_THIS_MULTI(IFilterGraphImpl
, IBasicVideo_vtbl
, iface
);
3453 IBasicVideo
* pBasicVideo
;
3456 TRACE("(%p/%p)->(%p)\n", This
, iface
, pDestinationHeight
);
3458 EnterCriticalSection(&This
->cs
);
3460 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3463 hr
= IBasicVideo_get_DestinationHeight(pBasicVideo
, pDestinationHeight
);
3465 LeaveCriticalSection(&This
->cs
);
3470 static HRESULT WINAPI
BasicVideo_SetSourcePosition(IBasicVideo2
*iface
,
3475 ICOM_THIS_MULTI(IFilterGraphImpl
, IBasicVideo_vtbl
, iface
);
3476 IBasicVideo
* pBasicVideo
;
3479 TRACE("(%p/%p)->(%ld, %ld, %ld, %ld)\n", This
, iface
, Left
, Top
, Width
, Height
);
3481 EnterCriticalSection(&This
->cs
);
3483 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3486 hr
= IBasicVideo_SetSourcePosition(pBasicVideo
, Left
, Top
, Width
, Height
);
3488 LeaveCriticalSection(&This
->cs
);
3493 static HRESULT WINAPI
BasicVideo_GetSourcePosition(IBasicVideo2
*iface
,
3498 ICOM_THIS_MULTI(IFilterGraphImpl
, IBasicVideo_vtbl
, iface
);
3499 IBasicVideo
* pBasicVideo
;
3502 TRACE("(%p/%p)->(%p, %p, %p, %p)\n", This
, iface
, pLeft
, pTop
, pWidth
, pHeight
);
3504 EnterCriticalSection(&This
->cs
);
3506 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3509 hr
= IBasicVideo_GetSourcePosition(pBasicVideo
, pLeft
, pTop
, pWidth
, pHeight
);
3511 LeaveCriticalSection(&This
->cs
);
3516 static HRESULT WINAPI
BasicVideo_SetDefaultSourcePosition(IBasicVideo2
*iface
) {
3517 ICOM_THIS_MULTI(IFilterGraphImpl
, IBasicVideo_vtbl
, iface
);
3518 IBasicVideo
* pBasicVideo
;
3521 TRACE("(%p/%p)->()\n", This
, iface
);
3523 EnterCriticalSection(&This
->cs
);
3525 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3528 hr
= IBasicVideo_SetDefaultSourcePosition(pBasicVideo
);
3530 LeaveCriticalSection(&This
->cs
);
3535 static HRESULT WINAPI
BasicVideo_SetDestinationPosition(IBasicVideo2
*iface
,
3540 ICOM_THIS_MULTI(IFilterGraphImpl
, IBasicVideo_vtbl
, iface
);
3541 IBasicVideo
* pBasicVideo
;
3544 TRACE("(%p/%p)->(%ld, %ld, %ld, %ld)\n", This
, iface
, Left
, Top
, Width
, Height
);
3546 EnterCriticalSection(&This
->cs
);
3548 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3551 hr
= IBasicVideo_SetDestinationPosition(pBasicVideo
, Left
, Top
, Width
, Height
);
3553 LeaveCriticalSection(&This
->cs
);
3558 static HRESULT WINAPI
BasicVideo_GetDestinationPosition(IBasicVideo2
*iface
,
3563 ICOM_THIS_MULTI(IFilterGraphImpl
, IBasicVideo_vtbl
, iface
);
3564 IBasicVideo
* pBasicVideo
;
3567 TRACE("(%p/%p)->(%p, %p, %p, %p)\n", This
, iface
, pLeft
, pTop
, pWidth
, pHeight
);
3569 EnterCriticalSection(&This
->cs
);
3571 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3574 hr
= IBasicVideo_GetDestinationPosition(pBasicVideo
, pLeft
, pTop
, pWidth
, pHeight
);
3576 LeaveCriticalSection(&This
->cs
);
3581 static HRESULT WINAPI
BasicVideo_SetDefaultDestinationPosition(IBasicVideo2
*iface
) {
3582 ICOM_THIS_MULTI(IFilterGraphImpl
, IBasicVideo_vtbl
, iface
);
3583 IBasicVideo
* pBasicVideo
;
3586 TRACE("(%p/%p)->()\n", This
, iface
);
3588 EnterCriticalSection(&This
->cs
);
3590 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3593 hr
= IBasicVideo_SetDefaultDestinationPosition(pBasicVideo
);
3595 LeaveCriticalSection(&This
->cs
);
3600 static HRESULT WINAPI
BasicVideo_GetVideoSize(IBasicVideo2
*iface
,
3603 ICOM_THIS_MULTI(IFilterGraphImpl
, IBasicVideo_vtbl
, iface
);
3604 IBasicVideo
* pBasicVideo
;
3607 TRACE("(%p/%p)->(%p, %p)\n", This
, iface
, pWidth
, pHeight
);
3609 EnterCriticalSection(&This
->cs
);
3611 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3614 hr
= IBasicVideo_GetVideoSize(pBasicVideo
, pWidth
, pHeight
);
3616 LeaveCriticalSection(&This
->cs
);
3621 static HRESULT WINAPI
BasicVideo_GetVideoPaletteEntries(IBasicVideo2
*iface
,
3626 ICOM_THIS_MULTI(IFilterGraphImpl
, IBasicVideo_vtbl
, iface
);
3627 IBasicVideo
* pBasicVideo
;
3630 TRACE("(%p/%p)->(%ld, %ld, %p, %p)\n", This
, iface
, StartIndex
, Entries
, pRetrieved
, pPalette
);
3632 EnterCriticalSection(&This
->cs
);
3634 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3637 hr
= IBasicVideo_GetVideoPaletteEntries(pBasicVideo
, StartIndex
, Entries
, pRetrieved
, pPalette
);
3639 LeaveCriticalSection(&This
->cs
);
3644 static HRESULT WINAPI
BasicVideo_GetCurrentImage(IBasicVideo2
*iface
,
3647 ICOM_THIS_MULTI(IFilterGraphImpl
, IBasicVideo_vtbl
, iface
);
3648 IBasicVideo
* pBasicVideo
;
3651 TRACE("(%p/%p)->(%p, %p)\n", This
, iface
, pBufferSize
, pDIBImage
);
3653 EnterCriticalSection(&This
->cs
);
3655 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3658 hr
= IBasicVideo_GetCurrentImage(pBasicVideo
, pBufferSize
, pDIBImage
);
3660 LeaveCriticalSection(&This
->cs
);
3665 static HRESULT WINAPI
BasicVideo_IsUsingDefaultSource(IBasicVideo2
*iface
) {
3666 ICOM_THIS_MULTI(IFilterGraphImpl
, IBasicVideo_vtbl
, iface
);
3667 IBasicVideo
* pBasicVideo
;
3670 TRACE("(%p/%p)->()\n", This
, iface
);
3672 EnterCriticalSection(&This
->cs
);
3674 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3677 hr
= IBasicVideo_IsUsingDefaultSource(pBasicVideo
);
3679 LeaveCriticalSection(&This
->cs
);
3684 static HRESULT WINAPI
BasicVideo_IsUsingDefaultDestination(IBasicVideo2
*iface
) {
3685 ICOM_THIS_MULTI(IFilterGraphImpl
, IBasicVideo_vtbl
, iface
);
3686 IBasicVideo
* pBasicVideo
;
3689 TRACE("(%p/%p)->()\n", This
, iface
);
3691 EnterCriticalSection(&This
->cs
);
3693 hr
= GetTargetInterface(This
, &IID_IBasicVideo
, (LPVOID
*)&pBasicVideo
);
3696 hr
= IBasicVideo_IsUsingDefaultDestination(pBasicVideo
);
3698 LeaveCriticalSection(&This
->cs
);
3703 static HRESULT WINAPI
BasicVideo2_GetPreferredAspectRatio(IBasicVideo2
*iface
, LONG
*plAspectX
, LONG
*plAspectY
) {
3704 ICOM_THIS_MULTI(IFilterGraphImpl
, IBasicVideo_vtbl
, iface
);
3705 IBasicVideo2
*pBasicVideo2
;
3708 TRACE("(%p/%p)->()\n", This
, iface
);
3710 EnterCriticalSection(&This
->cs
);
3712 hr
= GetTargetInterface(This
, &IID_IBasicVideo2
, (LPVOID
*)&pBasicVideo2
);
3715 hr
= BasicVideo2_GetPreferredAspectRatio(iface
, plAspectX
, plAspectY
);
3717 LeaveCriticalSection(&This
->cs
);
3722 static const IBasicVideo2Vtbl IBasicVideo_VTable
=
3724 BasicVideo_QueryInterface
,
3727 BasicVideo_GetTypeInfoCount
,
3728 BasicVideo_GetTypeInfo
,
3729 BasicVideo_GetIDsOfNames
,
3731 BasicVideo_get_AvgTimePerFrame
,
3732 BasicVideo_get_BitRate
,
3733 BasicVideo_get_BitErrorRate
,
3734 BasicVideo_get_VideoWidth
,
3735 BasicVideo_get_VideoHeight
,
3736 BasicVideo_put_SourceLeft
,
3737 BasicVideo_get_SourceLeft
,
3738 BasicVideo_put_SourceWidth
,
3739 BasicVideo_get_SourceWidth
,
3740 BasicVideo_put_SourceTop
,
3741 BasicVideo_get_SourceTop
,
3742 BasicVideo_put_SourceHeight
,
3743 BasicVideo_get_SourceHeight
,
3744 BasicVideo_put_DestinationLeft
,
3745 BasicVideo_get_DestinationLeft
,
3746 BasicVideo_put_DestinationWidth
,
3747 BasicVideo_get_DestinationWidth
,
3748 BasicVideo_put_DestinationTop
,
3749 BasicVideo_get_DestinationTop
,
3750 BasicVideo_put_DestinationHeight
,
3751 BasicVideo_get_DestinationHeight
,
3752 BasicVideo_SetSourcePosition
,
3753 BasicVideo_GetSourcePosition
,
3754 BasicVideo_SetDefaultSourcePosition
,
3755 BasicVideo_SetDestinationPosition
,
3756 BasicVideo_GetDestinationPosition
,
3757 BasicVideo_SetDefaultDestinationPosition
,
3758 BasicVideo_GetVideoSize
,
3759 BasicVideo_GetVideoPaletteEntries
,
3760 BasicVideo_GetCurrentImage
,
3761 BasicVideo_IsUsingDefaultSource
,
3762 BasicVideo_IsUsingDefaultDestination
,
3763 BasicVideo2_GetPreferredAspectRatio
3767 /*** IUnknown methods ***/
3768 static HRESULT WINAPI
VideoWindow_QueryInterface(IVideoWindow
*iface
,
3771 ICOM_THIS_MULTI(IFilterGraphImpl
, IVideoWindow_vtbl
, iface
);
3773 TRACE("(%p/%p)->(%s (%p), %p)\n", This
, iface
, debugstr_guid(riid
), riid
, ppvObj
);
3775 return Filtergraph_QueryInterface(This
, riid
, ppvObj
);
3778 static ULONG WINAPI
VideoWindow_AddRef(IVideoWindow
*iface
) {
3779 ICOM_THIS_MULTI(IFilterGraphImpl
, IVideoWindow_vtbl
, iface
);
3781 TRACE("(%p/%p)->()\n", This
, iface
);
3783 return Filtergraph_AddRef(This
);
3786 static ULONG WINAPI
VideoWindow_Release(IVideoWindow
*iface
) {
3787 ICOM_THIS_MULTI(IFilterGraphImpl
, IVideoWindow_vtbl
, iface
);
3789 TRACE("(%p/%p)->()\n", This
, iface
);
3791 return Filtergraph_Release(This
);
3794 /*** IDispatch methods ***/
3795 static HRESULT WINAPI
VideoWindow_GetTypeInfoCount(IVideoWindow
*iface
,
3797 ICOM_THIS_MULTI(IFilterGraphImpl
, IVideoWindow_vtbl
, iface
);
3798 IVideoWindow
* pVideoWindow
;
3801 TRACE("(%p/%p)->(%p)\n", This
, iface
, pctinfo
);
3803 EnterCriticalSection(&This
->cs
);
3805 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
3808 hr
= IVideoWindow_GetTypeInfoCount(pVideoWindow
, pctinfo
);
3810 LeaveCriticalSection(&This
->cs
);
3815 static HRESULT WINAPI
VideoWindow_GetTypeInfo(IVideoWindow
*iface
,
3818 ITypeInfo
**ppTInfo
) {
3819 ICOM_THIS_MULTI(IFilterGraphImpl
, IVideoWindow_vtbl
, iface
);
3820 IVideoWindow
* pVideoWindow
;
3823 TRACE("(%p/%p)->(%d, %d, %p)\n", This
, iface
, iTInfo
, lcid
, ppTInfo
);
3825 EnterCriticalSection(&This
->cs
);
3827 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
3830 hr
= IVideoWindow_GetTypeInfo(pVideoWindow
, iTInfo
, lcid
, ppTInfo
);
3832 LeaveCriticalSection(&This
->cs
);
3837 static HRESULT WINAPI
VideoWindow_GetIDsOfNames(IVideoWindow
*iface
,
3843 ICOM_THIS_MULTI(IFilterGraphImpl
, IVideoWindow_vtbl
, iface
);
3844 IVideoWindow
* pVideoWindow
;
3847 TRACE("(%p/%p)->(%s (%p), %p, %d, %d, %p)\n", This
, iface
, debugstr_guid(riid
), riid
, rgszNames
, cNames
, lcid
, rgDispId
);
3849 EnterCriticalSection(&This
->cs
);
3851 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
3854 hr
= IVideoWindow_GetIDsOfNames(pVideoWindow
, riid
, rgszNames
, cNames
, lcid
, rgDispId
);
3856 LeaveCriticalSection(&This
->cs
);
3861 static HRESULT WINAPI
VideoWindow_Invoke(IVideoWindow
*iface
,
3862 DISPID dispIdMember
,
3866 DISPPARAMS
*pDispParams
,
3868 EXCEPINFO
*pExepInfo
,
3870 ICOM_THIS_MULTI(IFilterGraphImpl
, IVideoWindow_vtbl
, iface
);
3871 IVideoWindow
* pVideoWindow
;
3874 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
);
3876 EnterCriticalSection(&This
->cs
);
3878 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
3881 hr
= IVideoWindow_Invoke(pVideoWindow
, dispIdMember
, riid
, lcid
, wFlags
, pDispParams
, pVarResult
, pExepInfo
, puArgErr
);
3883 LeaveCriticalSection(&This
->cs
);
3889 /*** IVideoWindow methods ***/
3890 static HRESULT WINAPI
VideoWindow_put_Caption(IVideoWindow
*iface
,
3892 ICOM_THIS_MULTI(IFilterGraphImpl
, IVideoWindow_vtbl
, iface
);
3893 IVideoWindow
* pVideoWindow
;
3896 TRACE("(%p/%p)->(%s (%p))\n", This
, iface
, debugstr_w(strCaption
), strCaption
);
3898 EnterCriticalSection(&This
->cs
);
3900 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
3903 hr
= IVideoWindow_put_Caption(pVideoWindow
, strCaption
);
3905 LeaveCriticalSection(&This
->cs
);
3910 static HRESULT WINAPI
VideoWindow_get_Caption(IVideoWindow
*iface
,
3912 ICOM_THIS_MULTI(IFilterGraphImpl
, IVideoWindow_vtbl
, iface
);
3913 IVideoWindow
* pVideoWindow
;
3916 TRACE("(%p/%p)->(%p)\n", This
, iface
, strCaption
);
3918 EnterCriticalSection(&This
->cs
);
3920 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
3923 hr
= IVideoWindow_get_Caption(pVideoWindow
, strCaption
);
3925 LeaveCriticalSection(&This
->cs
);
3930 static HRESULT WINAPI
VideoWindow_put_WindowStyle(IVideoWindow
*iface
,
3932 ICOM_THIS_MULTI(IFilterGraphImpl
, IVideoWindow_vtbl
, iface
);
3933 IVideoWindow
* pVideoWindow
;
3936 TRACE("(%p/%p)->(%ld)\n", This
, iface
, WindowStyle
);
3938 EnterCriticalSection(&This
->cs
);
3940 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
3943 hr
= IVideoWindow_put_WindowStyle(pVideoWindow
, WindowStyle
);
3945 LeaveCriticalSection(&This
->cs
);
3950 static HRESULT WINAPI
VideoWindow_get_WindowStyle(IVideoWindow
*iface
,
3951 long *WindowStyle
) {
3952 ICOM_THIS_MULTI(IFilterGraphImpl
, IVideoWindow_vtbl
, iface
);
3953 IVideoWindow
* pVideoWindow
;
3956 TRACE("(%p/%p)->(%p)\n", This
, iface
, WindowStyle
);
3958 EnterCriticalSection(&This
->cs
);
3960 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
3963 hr
= IVideoWindow_get_WindowStyle(pVideoWindow
, WindowStyle
);
3965 LeaveCriticalSection(&This
->cs
);
3970 static HRESULT WINAPI
VideoWindow_put_WindowStyleEx(IVideoWindow
*iface
,
3971 long WindowStyleEx
) {
3972 ICOM_THIS_MULTI(IFilterGraphImpl
, IVideoWindow_vtbl
, iface
);
3973 IVideoWindow
* pVideoWindow
;
3976 TRACE("(%p/%p)->(%ld)\n", This
, iface
, WindowStyleEx
);
3978 EnterCriticalSection(&This
->cs
);
3980 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
3983 hr
= IVideoWindow_put_WindowStyleEx(pVideoWindow
, WindowStyleEx
);
3985 LeaveCriticalSection(&This
->cs
);
3990 static HRESULT WINAPI
VideoWindow_get_WindowStyleEx(IVideoWindow
*iface
,
3991 long *WindowStyleEx
) {
3992 ICOM_THIS_MULTI(IFilterGraphImpl
, IVideoWindow_vtbl
, iface
);
3993 IVideoWindow
* pVideoWindow
;
3996 TRACE("(%p/%p)->(%p)\n", This
, iface
, WindowStyleEx
);
3998 EnterCriticalSection(&This
->cs
);
4000 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4003 hr
= IVideoWindow_get_WindowStyleEx(pVideoWindow
, WindowStyleEx
);
4005 LeaveCriticalSection(&This
->cs
);
4010 static HRESULT WINAPI
VideoWindow_put_AutoShow(IVideoWindow
*iface
,
4012 ICOM_THIS_MULTI(IFilterGraphImpl
, IVideoWindow_vtbl
, iface
);
4013 IVideoWindow
* pVideoWindow
;
4016 TRACE("(%p/%p)->(%ld)\n", This
, iface
, AutoShow
);
4018 EnterCriticalSection(&This
->cs
);
4020 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4023 hr
= IVideoWindow_put_AutoShow(pVideoWindow
, AutoShow
);
4025 LeaveCriticalSection(&This
->cs
);
4030 static HRESULT WINAPI
VideoWindow_get_AutoShow(IVideoWindow
*iface
,
4032 ICOM_THIS_MULTI(IFilterGraphImpl
, IVideoWindow_vtbl
, iface
);
4033 IVideoWindow
* pVideoWindow
;
4036 TRACE("(%p/%p)->(%p)\n", This
, iface
, AutoShow
);
4038 EnterCriticalSection(&This
->cs
);
4040 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4043 hr
= IVideoWindow_get_AutoShow(pVideoWindow
, AutoShow
);
4045 LeaveCriticalSection(&This
->cs
);
4050 static HRESULT WINAPI
VideoWindow_put_WindowState(IVideoWindow
*iface
,
4052 ICOM_THIS_MULTI(IFilterGraphImpl
, IVideoWindow_vtbl
, iface
);
4053 IVideoWindow
* pVideoWindow
;
4056 TRACE("(%p/%p)->(%ld)\n", This
, iface
, WindowState
);
4058 EnterCriticalSection(&This
->cs
);
4060 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4063 hr
= IVideoWindow_put_WindowState(pVideoWindow
, WindowState
);
4065 LeaveCriticalSection(&This
->cs
);
4070 static HRESULT WINAPI
VideoWindow_get_WindowState(IVideoWindow
*iface
,
4071 long *WindowState
) {
4072 ICOM_THIS_MULTI(IFilterGraphImpl
, IVideoWindow_vtbl
, iface
);
4073 IVideoWindow
* pVideoWindow
;
4076 TRACE("(%p/%p)->(%p)\n", This
, iface
, WindowState
);
4078 EnterCriticalSection(&This
->cs
);
4080 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4083 hr
= IVideoWindow_get_WindowState(pVideoWindow
, WindowState
);
4085 LeaveCriticalSection(&This
->cs
);
4090 static HRESULT WINAPI
VideoWindow_put_BackgroundPalette(IVideoWindow
*iface
,
4091 long BackgroundPalette
) {
4092 ICOM_THIS_MULTI(IFilterGraphImpl
, IVideoWindow_vtbl
, iface
);
4093 IVideoWindow
* pVideoWindow
;
4096 TRACE("(%p/%p)->(%ld)\n", This
, iface
, BackgroundPalette
);
4098 EnterCriticalSection(&This
->cs
);
4100 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4103 hr
= IVideoWindow_put_BackgroundPalette(pVideoWindow
, BackgroundPalette
);
4105 LeaveCriticalSection(&This
->cs
);
4110 static HRESULT WINAPI
VideoWindow_get_BackgroundPalette(IVideoWindow
*iface
,
4111 long *pBackgroundPalette
) {
4112 ICOM_THIS_MULTI(IFilterGraphImpl
, IVideoWindow_vtbl
, iface
);
4113 IVideoWindow
* pVideoWindow
;
4116 TRACE("(%p/%p)->(%p)\n", This
, iface
, pBackgroundPalette
);
4118 EnterCriticalSection(&This
->cs
);
4120 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4123 hr
= IVideoWindow_get_BackgroundPalette(pVideoWindow
, pBackgroundPalette
);
4125 LeaveCriticalSection(&This
->cs
);
4130 static HRESULT WINAPI
VideoWindow_put_Visible(IVideoWindow
*iface
,
4132 ICOM_THIS_MULTI(IFilterGraphImpl
, IVideoWindow_vtbl
, iface
);
4133 IVideoWindow
* pVideoWindow
;
4136 TRACE("(%p/%p)->(%ld)\n", This
, iface
, Visible
);
4138 EnterCriticalSection(&This
->cs
);
4140 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4143 hr
= IVideoWindow_put_Visible(pVideoWindow
, Visible
);
4145 LeaveCriticalSection(&This
->cs
);
4150 static HRESULT WINAPI
VideoWindow_get_Visible(IVideoWindow
*iface
,
4152 ICOM_THIS_MULTI(IFilterGraphImpl
, IVideoWindow_vtbl
, iface
);
4153 IVideoWindow
* pVideoWindow
;
4156 TRACE("(%p/%p)->(%p)\n", This
, iface
, pVisible
);
4158 EnterCriticalSection(&This
->cs
);
4160 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4163 hr
= IVideoWindow_get_Visible(pVideoWindow
, pVisible
);
4165 LeaveCriticalSection(&This
->cs
);
4170 static HRESULT WINAPI
VideoWindow_put_Left(IVideoWindow
*iface
,
4172 ICOM_THIS_MULTI(IFilterGraphImpl
, IVideoWindow_vtbl
, iface
);
4173 IVideoWindow
* pVideoWindow
;
4176 TRACE("(%p/%p)->(%ld)\n", This
, iface
, Left
);
4178 EnterCriticalSection(&This
->cs
);
4180 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4183 hr
= IVideoWindow_put_Left(pVideoWindow
, Left
);
4185 LeaveCriticalSection(&This
->cs
);
4190 static HRESULT WINAPI
VideoWindow_get_Left(IVideoWindow
*iface
,
4192 ICOM_THIS_MULTI(IFilterGraphImpl
, IVideoWindow_vtbl
, iface
);
4193 IVideoWindow
* pVideoWindow
;
4196 TRACE("(%p/%p)->(%p)\n", This
, iface
, pLeft
);
4198 EnterCriticalSection(&This
->cs
);
4200 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4203 hr
= IVideoWindow_get_Left(pVideoWindow
, pLeft
);
4205 LeaveCriticalSection(&This
->cs
);
4210 static HRESULT WINAPI
VideoWindow_put_Width(IVideoWindow
*iface
,
4212 ICOM_THIS_MULTI(IFilterGraphImpl
, IVideoWindow_vtbl
, iface
);
4213 IVideoWindow
* pVideoWindow
;
4216 TRACE("(%p/%p)->(%ld)\n", This
, iface
, Width
);
4218 EnterCriticalSection(&This
->cs
);
4220 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4223 hr
= IVideoWindow_put_Width(pVideoWindow
, Width
);
4225 LeaveCriticalSection(&This
->cs
);
4230 static HRESULT WINAPI
VideoWindow_get_Width(IVideoWindow
*iface
,
4232 ICOM_THIS_MULTI(IFilterGraphImpl
, IVideoWindow_vtbl
, iface
);
4233 IVideoWindow
* pVideoWindow
;
4236 TRACE("(%p/%p)->(%p)\n", This
, iface
, pWidth
);
4238 EnterCriticalSection(&This
->cs
);
4240 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4243 hr
= IVideoWindow_get_Width(pVideoWindow
, pWidth
);
4245 LeaveCriticalSection(&This
->cs
);
4250 static HRESULT WINAPI
VideoWindow_put_Top(IVideoWindow
*iface
,
4252 ICOM_THIS_MULTI(IFilterGraphImpl
, IVideoWindow_vtbl
, iface
);
4253 IVideoWindow
* pVideoWindow
;
4256 TRACE("(%p/%p)->(%ld)\n", This
, iface
, Top
);
4258 EnterCriticalSection(&This
->cs
);
4260 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4263 hr
= IVideoWindow_put_Top(pVideoWindow
, Top
);
4265 LeaveCriticalSection(&This
->cs
);
4270 static HRESULT WINAPI
VideoWindow_get_Top(IVideoWindow
*iface
,
4272 ICOM_THIS_MULTI(IFilterGraphImpl
, IVideoWindow_vtbl
, iface
);
4273 IVideoWindow
* pVideoWindow
;
4276 TRACE("(%p/%p)->(%p)\n", This
, iface
, pTop
);
4278 EnterCriticalSection(&This
->cs
);
4280 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4283 hr
= IVideoWindow_get_Top(pVideoWindow
, pTop
);
4285 LeaveCriticalSection(&This
->cs
);
4290 static HRESULT WINAPI
VideoWindow_put_Height(IVideoWindow
*iface
,
4292 ICOM_THIS_MULTI(IFilterGraphImpl
, IVideoWindow_vtbl
, iface
);
4293 IVideoWindow
* pVideoWindow
;
4296 TRACE("(%p/%p)->(%ld)\n", This
, iface
, Height
);
4298 EnterCriticalSection(&This
->cs
);
4300 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4303 hr
= IVideoWindow_put_Height(pVideoWindow
, Height
);
4305 LeaveCriticalSection(&This
->cs
);
4310 static HRESULT WINAPI
VideoWindow_get_Height(IVideoWindow
*iface
,
4312 ICOM_THIS_MULTI(IFilterGraphImpl
, IVideoWindow_vtbl
, iface
);
4313 IVideoWindow
* pVideoWindow
;
4316 TRACE("(%p/%p)->(%p)\n", This
, iface
, pHeight
);
4318 EnterCriticalSection(&This
->cs
);
4320 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4323 hr
= IVideoWindow_get_Height(pVideoWindow
, pHeight
);
4325 LeaveCriticalSection(&This
->cs
);
4330 static HRESULT WINAPI
VideoWindow_put_Owner(IVideoWindow
*iface
,
4332 ICOM_THIS_MULTI(IFilterGraphImpl
, IVideoWindow_vtbl
, iface
);
4333 IVideoWindow
* pVideoWindow
;
4336 TRACE("(%p/%p)->(%08x)\n", This
, iface
, (DWORD
) Owner
);
4338 EnterCriticalSection(&This
->cs
);
4340 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4343 hr
= IVideoWindow_put_Owner(pVideoWindow
, Owner
);
4345 LeaveCriticalSection(&This
->cs
);
4350 static HRESULT WINAPI
VideoWindow_get_Owner(IVideoWindow
*iface
,
4352 ICOM_THIS_MULTI(IFilterGraphImpl
, IVideoWindow_vtbl
, iface
);
4353 IVideoWindow
* pVideoWindow
;
4356 TRACE("(%p/%p)->(%p)\n", This
, iface
, Owner
);
4358 EnterCriticalSection(&This
->cs
);
4360 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4363 hr
= IVideoWindow_get_Owner(pVideoWindow
, Owner
);
4365 LeaveCriticalSection(&This
->cs
);
4370 static HRESULT WINAPI
VideoWindow_put_MessageDrain(IVideoWindow
*iface
,
4372 ICOM_THIS_MULTI(IFilterGraphImpl
, IVideoWindow_vtbl
, iface
);
4373 IVideoWindow
* pVideoWindow
;
4376 TRACE("(%p/%p)->(%08x)\n", This
, iface
, (DWORD
) Drain
);
4378 EnterCriticalSection(&This
->cs
);
4380 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4383 hr
= IVideoWindow_put_MessageDrain(pVideoWindow
, Drain
);
4385 LeaveCriticalSection(&This
->cs
);
4390 static HRESULT WINAPI
VideoWindow_get_MessageDrain(IVideoWindow
*iface
,
4392 ICOM_THIS_MULTI(IFilterGraphImpl
, IVideoWindow_vtbl
, iface
);
4393 IVideoWindow
* pVideoWindow
;
4396 TRACE("(%p/%p)->(%p)\n", This
, iface
, Drain
);
4398 EnterCriticalSection(&This
->cs
);
4400 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4403 hr
= IVideoWindow_get_MessageDrain(pVideoWindow
, Drain
);
4405 LeaveCriticalSection(&This
->cs
);
4410 static HRESULT WINAPI
VideoWindow_get_BorderColor(IVideoWindow
*iface
,
4412 ICOM_THIS_MULTI(IFilterGraphImpl
, IVideoWindow_vtbl
, iface
);
4413 IVideoWindow
* pVideoWindow
;
4416 TRACE("(%p/%p)->(%p)\n", This
, iface
, Color
);
4418 EnterCriticalSection(&This
->cs
);
4420 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4423 hr
= IVideoWindow_get_BorderColor(pVideoWindow
, Color
);
4425 LeaveCriticalSection(&This
->cs
);
4430 static HRESULT WINAPI
VideoWindow_put_BorderColor(IVideoWindow
*iface
,
4432 ICOM_THIS_MULTI(IFilterGraphImpl
, IVideoWindow_vtbl
, iface
);
4433 IVideoWindow
* pVideoWindow
;
4436 TRACE("(%p/%p)->(%ld)\n", This
, iface
, Color
);
4438 EnterCriticalSection(&This
->cs
);
4440 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4443 hr
= IVideoWindow_put_BorderColor(pVideoWindow
, Color
);
4445 LeaveCriticalSection(&This
->cs
);
4450 static HRESULT WINAPI
VideoWindow_get_FullScreenMode(IVideoWindow
*iface
,
4451 long *FullScreenMode
) {
4452 ICOM_THIS_MULTI(IFilterGraphImpl
, IVideoWindow_vtbl
, iface
);
4453 IVideoWindow
* pVideoWindow
;
4456 TRACE("(%p/%p)->(%p)\n", This
, iface
, FullScreenMode
);
4458 EnterCriticalSection(&This
->cs
);
4460 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4463 hr
= IVideoWindow_get_FullScreenMode(pVideoWindow
, FullScreenMode
);
4465 LeaveCriticalSection(&This
->cs
);
4470 static HRESULT WINAPI
VideoWindow_put_FullScreenMode(IVideoWindow
*iface
,
4471 long FullScreenMode
) {
4472 ICOM_THIS_MULTI(IFilterGraphImpl
, IVideoWindow_vtbl
, iface
);
4473 IVideoWindow
* pVideoWindow
;
4476 TRACE("(%p/%p)->(%ld)\n", This
, iface
, FullScreenMode
);
4478 EnterCriticalSection(&This
->cs
);
4480 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4483 hr
= IVideoWindow_put_FullScreenMode(pVideoWindow
, FullScreenMode
);
4485 LeaveCriticalSection(&This
->cs
);
4490 static HRESULT WINAPI
VideoWindow_SetWindowForeground(IVideoWindow
*iface
,
4492 ICOM_THIS_MULTI(IFilterGraphImpl
, IVideoWindow_vtbl
, iface
);
4493 IVideoWindow
* pVideoWindow
;
4496 TRACE("(%p/%p)->(%ld)\n", This
, iface
, Focus
);
4498 EnterCriticalSection(&This
->cs
);
4500 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4503 hr
= IVideoWindow_SetWindowForeground(pVideoWindow
, Focus
);
4505 LeaveCriticalSection(&This
->cs
);
4510 static HRESULT WINAPI
VideoWindow_NotifyOwnerMessage(IVideoWindow
*iface
,
4515 ICOM_THIS_MULTI(IFilterGraphImpl
, IVideoWindow_vtbl
, iface
);
4516 IVideoWindow
* pVideoWindow
;
4519 TRACE("(%p/%p)->(%08x, %ld, %08lx, %08lx)\n", This
, iface
, (DWORD
) hwnd
, uMsg
, wParam
, lParam
);
4521 EnterCriticalSection(&This
->cs
);
4523 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4526 hr
= IVideoWindow_NotifyOwnerMessage(pVideoWindow
, hwnd
, uMsg
, wParam
, lParam
);
4528 LeaveCriticalSection(&This
->cs
);
4533 static HRESULT WINAPI
VideoWindow_SetWindowPosition(IVideoWindow
*iface
,
4538 ICOM_THIS_MULTI(IFilterGraphImpl
, IVideoWindow_vtbl
, iface
);
4539 IVideoWindow
* pVideoWindow
;
4542 TRACE("(%p/%p)->(%ld, %ld, %ld, %ld)\n", This
, iface
, Left
, Top
, Width
, Height
);
4544 EnterCriticalSection(&This
->cs
);
4546 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4549 hr
= IVideoWindow_SetWindowPosition(pVideoWindow
, Left
, Top
, Width
, Height
);
4551 LeaveCriticalSection(&This
->cs
);
4556 static HRESULT WINAPI
VideoWindow_GetWindowPosition(IVideoWindow
*iface
,
4561 ICOM_THIS_MULTI(IFilterGraphImpl
, IVideoWindow_vtbl
, iface
);
4562 IVideoWindow
* pVideoWindow
;
4565 TRACE("(%p/%p)->(%p, %p, %p, %p)\n", This
, iface
, pLeft
, pTop
, pWidth
, pHeight
);
4567 EnterCriticalSection(&This
->cs
);
4569 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4572 hr
= IVideoWindow_GetWindowPosition(pVideoWindow
, pLeft
, pTop
, pWidth
, pHeight
);
4574 LeaveCriticalSection(&This
->cs
);
4579 static HRESULT WINAPI
VideoWindow_GetMinIdealImageSize(IVideoWindow
*iface
,
4582 ICOM_THIS_MULTI(IFilterGraphImpl
, IVideoWindow_vtbl
, iface
);
4583 IVideoWindow
* pVideoWindow
;
4586 TRACE("(%p/%p)->(%p, %p)\n", This
, iface
, pWidth
, pHeight
);
4588 EnterCriticalSection(&This
->cs
);
4590 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4593 hr
= IVideoWindow_GetMinIdealImageSize(pVideoWindow
, pWidth
, pHeight
);
4595 LeaveCriticalSection(&This
->cs
);
4600 static HRESULT WINAPI
VideoWindow_GetMaxIdealImageSize(IVideoWindow
*iface
,
4603 ICOM_THIS_MULTI(IFilterGraphImpl
, IVideoWindow_vtbl
, iface
);
4604 IVideoWindow
* pVideoWindow
;
4607 TRACE("(%p/%p)->(%p, %p)\n", This
, iface
, pWidth
, pHeight
);
4609 EnterCriticalSection(&This
->cs
);
4611 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4614 hr
= IVideoWindow_GetMaxIdealImageSize(pVideoWindow
, pWidth
, pHeight
);
4616 LeaveCriticalSection(&This
->cs
);
4621 static HRESULT WINAPI
VideoWindow_GetRestorePosition(IVideoWindow
*iface
,
4626 ICOM_THIS_MULTI(IFilterGraphImpl
, IVideoWindow_vtbl
, iface
);
4627 IVideoWindow
* pVideoWindow
;
4630 TRACE("(%p/%p)->(%p, %p, %p, %p)\n", This
, iface
, pLeft
, pTop
, pWidth
, pHeight
);
4632 EnterCriticalSection(&This
->cs
);
4634 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4637 hr
= IVideoWindow_GetRestorePosition(pVideoWindow
, pLeft
, pTop
, pWidth
, pHeight
);
4639 LeaveCriticalSection(&This
->cs
);
4644 static HRESULT WINAPI
VideoWindow_HideCursor(IVideoWindow
*iface
,
4646 ICOM_THIS_MULTI(IFilterGraphImpl
, IVideoWindow_vtbl
, iface
);
4647 IVideoWindow
* pVideoWindow
;
4650 TRACE("(%p/%p)->(%ld)\n", This
, iface
, HideCursor
);
4652 EnterCriticalSection(&This
->cs
);
4654 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4657 hr
= IVideoWindow_HideCursor(pVideoWindow
, HideCursor
);
4659 LeaveCriticalSection(&This
->cs
);
4664 static HRESULT WINAPI
VideoWindow_IsCursorHidden(IVideoWindow
*iface
,
4665 long *CursorHidden
) {
4666 ICOM_THIS_MULTI(IFilterGraphImpl
, IVideoWindow_vtbl
, iface
);
4667 IVideoWindow
* pVideoWindow
;
4670 TRACE("(%p/%p)->(%p)\n", This
, iface
, CursorHidden
);
4672 EnterCriticalSection(&This
->cs
);
4674 hr
= GetTargetInterface(This
, &IID_IVideoWindow
, (LPVOID
*)&pVideoWindow
);
4677 hr
= IVideoWindow_IsCursorHidden(pVideoWindow
, CursorHidden
);
4679 LeaveCriticalSection(&This
->cs
);
4685 static const IVideoWindowVtbl IVideoWindow_VTable
=
4687 VideoWindow_QueryInterface
,
4689 VideoWindow_Release
,
4690 VideoWindow_GetTypeInfoCount
,
4691 VideoWindow_GetTypeInfo
,
4692 VideoWindow_GetIDsOfNames
,
4694 VideoWindow_put_Caption
,
4695 VideoWindow_get_Caption
,
4696 VideoWindow_put_WindowStyle
,
4697 VideoWindow_get_WindowStyle
,
4698 VideoWindow_put_WindowStyleEx
,
4699 VideoWindow_get_WindowStyleEx
,
4700 VideoWindow_put_AutoShow
,
4701 VideoWindow_get_AutoShow
,
4702 VideoWindow_put_WindowState
,
4703 VideoWindow_get_WindowState
,
4704 VideoWindow_put_BackgroundPalette
,
4705 VideoWindow_get_BackgroundPalette
,
4706 VideoWindow_put_Visible
,
4707 VideoWindow_get_Visible
,
4708 VideoWindow_put_Left
,
4709 VideoWindow_get_Left
,
4710 VideoWindow_put_Width
,
4711 VideoWindow_get_Width
,
4712 VideoWindow_put_Top
,
4713 VideoWindow_get_Top
,
4714 VideoWindow_put_Height
,
4715 VideoWindow_get_Height
,
4716 VideoWindow_put_Owner
,
4717 VideoWindow_get_Owner
,
4718 VideoWindow_put_MessageDrain
,
4719 VideoWindow_get_MessageDrain
,
4720 VideoWindow_get_BorderColor
,
4721 VideoWindow_put_BorderColor
,
4722 VideoWindow_get_FullScreenMode
,
4723 VideoWindow_put_FullScreenMode
,
4724 VideoWindow_SetWindowForeground
,
4725 VideoWindow_NotifyOwnerMessage
,
4726 VideoWindow_SetWindowPosition
,
4727 VideoWindow_GetWindowPosition
,
4728 VideoWindow_GetMinIdealImageSize
,
4729 VideoWindow_GetMaxIdealImageSize
,
4730 VideoWindow_GetRestorePosition
,
4731 VideoWindow_HideCursor
,
4732 VideoWindow_IsCursorHidden
4736 /*** IUnknown methods ***/
4737 static HRESULT WINAPI
MediaEvent_QueryInterface(IMediaEventEx
*iface
,
4740 ICOM_THIS_MULTI(IFilterGraphImpl
, IMediaEventEx_vtbl
, iface
);
4742 TRACE("(%p/%p)->(%s (%p), %p)\n", This
, iface
, debugstr_guid(riid
), riid
, ppvObj
);
4744 return Filtergraph_QueryInterface(This
, riid
, ppvObj
);
4747 static ULONG WINAPI
MediaEvent_AddRef(IMediaEventEx
*iface
) {
4748 ICOM_THIS_MULTI(IFilterGraphImpl
, IMediaEventEx_vtbl
, iface
);
4750 TRACE("(%p/%p)->()\n", This
, iface
);
4752 return Filtergraph_AddRef(This
);
4755 static ULONG WINAPI
MediaEvent_Release(IMediaEventEx
*iface
) {
4756 ICOM_THIS_MULTI(IFilterGraphImpl
, IMediaEventEx_vtbl
, iface
);
4758 TRACE("(%p/%p)->()\n", This
, iface
);
4760 return Filtergraph_Release(This
);
4763 /*** IDispatch methods ***/
4764 static HRESULT WINAPI
MediaEvent_GetTypeInfoCount(IMediaEventEx
*iface
,
4766 ICOM_THIS_MULTI(IFilterGraphImpl
, IMediaEventEx_vtbl
, iface
);
4768 TRACE("(%p/%p)->(%p): stub !!!\n", This
, iface
, pctinfo
);
4773 static HRESULT WINAPI
MediaEvent_GetTypeInfo(IMediaEventEx
*iface
,
4776 ITypeInfo
**ppTInfo
) {
4777 ICOM_THIS_MULTI(IFilterGraphImpl
, IMediaEventEx_vtbl
, iface
);
4779 TRACE("(%p/%p)->(%d, %d, %p): stub !!!\n", This
, iface
, iTInfo
, lcid
, ppTInfo
);
4784 static HRESULT WINAPI
MediaEvent_GetIDsOfNames(IMediaEventEx
*iface
,
4790 ICOM_THIS_MULTI(IFilterGraphImpl
, IMediaEventEx_vtbl
, iface
);
4792 TRACE("(%p/%p)->(%s (%p), %p, %d, %d, %p): stub !!!\n", This
, iface
, debugstr_guid(riid
), riid
, rgszNames
, cNames
, lcid
, rgDispId
);
4797 static HRESULT WINAPI
MediaEvent_Invoke(IMediaEventEx
*iface
,
4798 DISPID dispIdMember
,
4802 DISPPARAMS
*pDispParams
,
4804 EXCEPINFO
*pExepInfo
,
4806 ICOM_THIS_MULTI(IFilterGraphImpl
, IMediaEventEx_vtbl
, iface
);
4808 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
);
4813 /*** IMediaEvent methods ***/
4814 static HRESULT WINAPI
MediaEvent_GetEventHandle(IMediaEventEx
*iface
,
4816 ICOM_THIS_MULTI(IFilterGraphImpl
, IMediaEventEx_vtbl
, iface
);
4818 TRACE("(%p/%p)->(%p)\n", This
, iface
, hEvent
);
4820 *hEvent
= (OAEVENT
)This
->evqueue
.msg_event
;
4825 static HRESULT WINAPI
MediaEvent_GetEvent(IMediaEventEx
*iface
,
4830 ICOM_THIS_MULTI(IFilterGraphImpl
, IMediaEventEx_vtbl
, iface
);
4833 TRACE("(%p/%p)->(%p, %p, %p, %ld)\n", This
, iface
, lEventCode
, lParam1
, lParam2
, msTimeout
);
4835 if (EventsQueue_GetEvent(&This
->evqueue
, &evt
, msTimeout
))
4837 *lEventCode
= evt
.lEventCode
;
4838 *lParam1
= evt
.lParam1
;
4839 *lParam2
= evt
.lParam2
;
4847 static HRESULT WINAPI
MediaEvent_WaitForCompletion(IMediaEventEx
*iface
,
4850 ICOM_THIS_MULTI(IFilterGraphImpl
, IMediaEventEx_vtbl
, iface
);
4852 TRACE("(%p/%p)->(%ld, %p)\n", This
, iface
, msTimeout
, pEvCode
);
4854 if (WaitForSingleObject(This
->hEventCompletion
, msTimeout
) == WAIT_OBJECT_0
)
4856 *pEvCode
= This
->CompletionStatus
;
4864 static HRESULT WINAPI
MediaEvent_CancelDefaultHandling(IMediaEventEx
*iface
,
4866 ICOM_THIS_MULTI(IFilterGraphImpl
, IMediaEventEx_vtbl
, iface
);
4868 TRACE("(%p/%p)->(%ld)\n", This
, iface
, lEvCode
);
4870 if (lEvCode
== EC_COMPLETE
)
4871 This
->HandleEcComplete
= FALSE
;
4872 else if (lEvCode
== EC_REPAINT
)
4873 This
->HandleEcRepaint
= FALSE
;
4874 else if (lEvCode
== EC_CLOCK_CHANGED
)
4875 This
->HandleEcClockChanged
= FALSE
;
4882 static HRESULT WINAPI
MediaEvent_RestoreDefaultHandling(IMediaEventEx
*iface
,
4884 ICOM_THIS_MULTI(IFilterGraphImpl
, IMediaEventEx_vtbl
, iface
);
4886 TRACE("(%p/%p)->(%ld)\n", This
, iface
, lEvCode
);
4888 if (lEvCode
== EC_COMPLETE
)
4889 This
->HandleEcComplete
= TRUE
;
4890 else if (lEvCode
== EC_REPAINT
)
4891 This
->HandleEcRepaint
= TRUE
;
4892 else if (lEvCode
== EC_CLOCK_CHANGED
)
4893 This
->HandleEcClockChanged
= TRUE
;
4900 static HRESULT WINAPI
MediaEvent_FreeEventParams(IMediaEventEx
*iface
,
4904 ICOM_THIS_MULTI(IFilterGraphImpl
, IMediaEventEx_vtbl
, iface
);
4906 TRACE("(%p/%p)->(%ld, %08lx, %08lx): stub !!!\n", This
, iface
, lEvCode
, lParam1
, lParam2
);
4911 /*** IMediaEventEx methods ***/
4912 static HRESULT WINAPI
MediaEvent_SetNotifyWindow(IMediaEventEx
*iface
,
4915 LONG_PTR lInstanceData
) {
4916 ICOM_THIS_MULTI(IFilterGraphImpl
, IMediaEventEx_vtbl
, iface
);
4918 TRACE("(%p/%p)->(%08x, %ld, %08lx)\n", This
, iface
, (DWORD
) hwnd
, lMsg
, lInstanceData
);
4920 This
->notif
.hWnd
= (HWND
)hwnd
;
4921 This
->notif
.msg
= lMsg
;
4922 This
->notif
.instance
= (long) lInstanceData
;
4927 static HRESULT WINAPI
MediaEvent_SetNotifyFlags(IMediaEventEx
*iface
,
4928 long lNoNotifyFlags
) {
4929 ICOM_THIS_MULTI(IFilterGraphImpl
, IMediaEventEx_vtbl
, iface
);
4931 TRACE("(%p/%p)->(%ld)\n", This
, iface
, lNoNotifyFlags
);
4933 if ((lNoNotifyFlags
!= 0) && (lNoNotifyFlags
!= 1))
4934 return E_INVALIDARG
;
4936 This
->notif
.disabled
= lNoNotifyFlags
;
4941 static HRESULT WINAPI
MediaEvent_GetNotifyFlags(IMediaEventEx
*iface
,
4942 long *lplNoNotifyFlags
) {
4943 ICOM_THIS_MULTI(IFilterGraphImpl
, IMediaEventEx_vtbl
, iface
);
4945 TRACE("(%p/%p)->(%p)\n", This
, iface
, lplNoNotifyFlags
);
4947 if (!lplNoNotifyFlags
)
4950 *lplNoNotifyFlags
= This
->notif
.disabled
;
4956 static const IMediaEventExVtbl IMediaEventEx_VTable
=
4958 MediaEvent_QueryInterface
,
4961 MediaEvent_GetTypeInfoCount
,
4962 MediaEvent_GetTypeInfo
,
4963 MediaEvent_GetIDsOfNames
,
4965 MediaEvent_GetEventHandle
,
4966 MediaEvent_GetEvent
,
4967 MediaEvent_WaitForCompletion
,
4968 MediaEvent_CancelDefaultHandling
,
4969 MediaEvent_RestoreDefaultHandling
,
4970 MediaEvent_FreeEventParams
,
4971 MediaEvent_SetNotifyWindow
,
4972 MediaEvent_SetNotifyFlags
,
4973 MediaEvent_GetNotifyFlags
4977 static HRESULT WINAPI
MediaFilter_QueryInterface(IMediaFilter
*iface
, REFIID riid
, LPVOID
*ppv
)
4979 ICOM_THIS_MULTI(IFilterGraphImpl
, IMediaFilter_vtbl
, iface
);
4981 return Filtergraph_QueryInterface(This
, riid
, ppv
);
4984 static ULONG WINAPI
MediaFilter_AddRef(IMediaFilter
*iface
)
4986 ICOM_THIS_MULTI(IFilterGraphImpl
, IMediaFilter_vtbl
, iface
);
4988 return Filtergraph_AddRef(This
);
4991 static ULONG WINAPI
MediaFilter_Release(IMediaFilter
*iface
)
4993 ICOM_THIS_MULTI(IFilterGraphImpl
, IMediaFilter_vtbl
, iface
);
4995 return Filtergraph_Release(This
);
4998 static HRESULT WINAPI
MediaFilter_GetClassID(IMediaFilter
*iface
, CLSID
* pClassID
)
5000 FIXME("(%p): stub\n", pClassID
);
5005 static HRESULT WINAPI
MediaFilter_Stop(IMediaFilter
*iface
)
5007 FIXME("(): stub\n");
5012 static HRESULT WINAPI
MediaFilter_Pause(IMediaFilter
*iface
)
5014 FIXME("(): stub\n");
5019 static HRESULT WINAPI
MediaFilter_Run(IMediaFilter
*iface
, REFERENCE_TIME tStart
)
5021 FIXME("(0x%s): stub\n", wine_dbgstr_longlong(tStart
));
5026 static HRESULT WINAPI
MediaFilter_GetState(IMediaFilter
*iface
, DWORD dwMsTimeout
, FILTER_STATE
* pState
)
5028 FIXME("(%d, %p): stub\n", dwMsTimeout
, pState
);
5033 static HRESULT WINAPI
MediaFilter_SetSyncSource(IMediaFilter
*iface
, IReferenceClock
*pClock
)
5035 ICOM_THIS_MULTI(IFilterGraphImpl
, IMediaFilter_vtbl
, iface
);
5039 TRACE("(%p/%p)->(%p)\n", iface
, This
, pClock
);
5041 EnterCriticalSection(&This
->cs
);
5043 for (i
= 0;i
< This
->nFilters
;i
++)
5045 hr
= IBaseFilter_SetSyncSource(This
->ppFiltersInGraph
[i
], pClock
);
5053 IBaseFilter_SetSyncSource(This
->ppFiltersInGraph
[i
], This
->refClock
);
5058 IReferenceClock_Release(This
->refClock
);
5059 This
->refClock
= pClock
;
5061 IReferenceClock_AddRef(This
->refClock
);
5063 if (This
->HandleEcClockChanged
)
5065 IMediaEventSink
*pEventSink
;
5068 eshr
= IMediaFilter_QueryInterface(iface
, &IID_IMediaEventSink
, (LPVOID
)&pEventSink
);
5069 if (SUCCEEDED(eshr
))
5071 IMediaEventSink_Notify(pEventSink
, EC_CLOCK_CHANGED
, 0, 0);
5072 IMediaEventSink_Release(pEventSink
);
5077 LeaveCriticalSection(&This
->cs
);
5082 static HRESULT WINAPI
MediaFilter_GetSyncSource(IMediaFilter
*iface
, IReferenceClock
**ppClock
)
5084 ICOM_THIS_MULTI(IFilterGraphImpl
, IMediaFilter_vtbl
, iface
);
5086 TRACE("(%p/%p)->(%p)\n", iface
, This
, ppClock
);
5091 EnterCriticalSection(&This
->cs
);
5093 *ppClock
= This
->refClock
;
5095 IReferenceClock_AddRef(*ppClock
);
5097 LeaveCriticalSection(&This
->cs
);
5102 static const IMediaFilterVtbl IMediaFilter_VTable
=
5104 MediaFilter_QueryInterface
,
5106 MediaFilter_Release
,
5107 MediaFilter_GetClassID
,
5111 MediaFilter_GetState
,
5112 MediaFilter_SetSyncSource
,
5113 MediaFilter_GetSyncSource
5116 static HRESULT WINAPI
MediaEventSink_QueryInterface(IMediaEventSink
*iface
, REFIID riid
, LPVOID
*ppv
)
5118 ICOM_THIS_MULTI(IFilterGraphImpl
, IMediaEventSink_vtbl
, iface
);
5120 return Filtergraph_QueryInterface(This
, riid
, ppv
);
5123 static ULONG WINAPI
MediaEventSink_AddRef(IMediaEventSink
*iface
)
5125 ICOM_THIS_MULTI(IFilterGraphImpl
, IMediaEventSink_vtbl
, iface
);
5127 return Filtergraph_AddRef(This
);
5130 static ULONG WINAPI
MediaEventSink_Release(IMediaEventSink
*iface
)
5132 ICOM_THIS_MULTI(IFilterGraphImpl
, IMediaEventSink_vtbl
, iface
);
5134 return Filtergraph_Release(This
);
5137 static HRESULT WINAPI
MediaEventSink_Notify(IMediaEventSink
*iface
, long EventCode
, LONG_PTR EventParam1
, LONG_PTR EventParam2
)
5139 ICOM_THIS_MULTI(IFilterGraphImpl
, IMediaEventSink_vtbl
, iface
);
5142 TRACE("(%p/%p)->(%ld, %ld, %ld)\n", This
, iface
, EventCode
, EventParam1
, EventParam2
);
5144 /* We need thread safety here, let's use the events queue's one */
5145 EnterCriticalSection(&This
->evqueue
.msg_crst
);
5147 if ((EventCode
== EC_COMPLETE
) && This
->HandleEcComplete
)
5149 TRACE("Process EC_COMPLETE notification\n");
5150 if (++This
->EcCompleteCount
== This
->nRenderers
)
5152 evt
.lEventCode
= EC_COMPLETE
;
5155 TRACE("Send EC_COMPLETE to app\n");
5156 EventsQueue_PutEvent(&This
->evqueue
, &evt
);
5157 if (!This
->notif
.disabled
&& This
->notif
.hWnd
)
5159 TRACE("Send Window message\n");
5160 PostMessageW(This
->notif
.hWnd
, This
->notif
.msg
, 0, This
->notif
.instance
);
5162 This
->CompletionStatus
= EC_COMPLETE
;
5163 SetEvent(This
->hEventCompletion
);
5166 else if ((EventCode
== EC_REPAINT
) && This
->HandleEcRepaint
)
5168 /* FIXME: Not handled yet */
5172 evt
.lEventCode
= EventCode
;
5173 evt
.lParam1
= EventParam1
;
5174 evt
.lParam2
= EventParam2
;
5175 EventsQueue_PutEvent(&This
->evqueue
, &evt
);
5176 if (!This
->notif
.disabled
&& This
->notif
.hWnd
)
5177 PostMessageW(This
->notif
.hWnd
, This
->notif
.msg
, 0, This
->notif
.instance
);
5180 LeaveCriticalSection(&This
->evqueue
.msg_crst
);
5184 static const IMediaEventSinkVtbl IMediaEventSink_VTable
=
5186 MediaEventSink_QueryInterface
,
5187 MediaEventSink_AddRef
,
5188 MediaEventSink_Release
,
5189 MediaEventSink_Notify
5192 static HRESULT WINAPI
GraphConfig_QueryInterface(IGraphConfig
*iface
, REFIID riid
, LPVOID
*ppv
)
5194 ICOM_THIS_MULTI(IFilterGraphImpl
, IGraphConfig_vtbl
, iface
);
5196 return Filtergraph_QueryInterface(This
, riid
, ppv
);
5199 static ULONG WINAPI
GraphConfig_AddRef(IGraphConfig
*iface
)
5201 ICOM_THIS_MULTI(IFilterGraphImpl
, IGraphConfig_vtbl
, iface
);
5203 return Filtergraph_AddRef(This
);
5206 static ULONG WINAPI
GraphConfig_Release(IGraphConfig
*iface
)
5208 ICOM_THIS_MULTI(IFilterGraphImpl
, IGraphConfig_vtbl
, iface
);
5210 return Filtergraph_Release(This
);
5213 static HRESULT WINAPI
GraphConfig_Reconnect(IGraphConfig
*iface
,
5216 const AM_MEDIA_TYPE
* pmtFirstConnection
,
5217 IBaseFilter
* pUsingFilter
,
5221 ICOM_THIS_MULTI(IFilterGraphImpl
, IGraphConfig_vtbl
, iface
);
5223 FIXME("(%p)->(%p, %p, %p, %p, %p, %x): stub!\n", This
, pOutputPin
, pInputPin
, pmtFirstConnection
, pUsingFilter
, hAbortEvent
, dwFlags
);
5228 static HRESULT WINAPI
GraphConfig_Reconfigure(IGraphConfig
*iface
,
5229 IGraphConfigCallback
* pCallback
,
5234 ICOM_THIS_MULTI(IFilterGraphImpl
, IGraphConfig_vtbl
, iface
);
5237 WARN("(%p)->(%p, %p, %x, %p): partial stub!\n", This
, pCallback
, pvContext
, dwFlags
, hAbortEvent
);
5240 FIXME("The parameter hAbortEvent is not handled!\n");
5242 EnterCriticalSection(&This
->cs
);
5244 hr
= IGraphConfigCallback_Reconfigure(pCallback
, pvContext
, dwFlags
);
5246 LeaveCriticalSection(&This
->cs
);
5251 static HRESULT WINAPI
GraphConfig_AddFilterToCache(IGraphConfig
*iface
,
5252 IBaseFilter
* pFilter
)
5254 ICOM_THIS_MULTI(IFilterGraphImpl
, IGraphConfig_vtbl
, iface
);
5256 FIXME("(%p)->(%p): stub!\n", This
, pFilter
);
5261 static HRESULT WINAPI
GraphConfig_EnumCacheFilter(IGraphConfig
*iface
,
5262 IEnumFilters
** pEnum
)
5264 ICOM_THIS_MULTI(IFilterGraphImpl
, IGraphConfig_vtbl
, iface
);
5266 FIXME("(%p)->(%p): stub!\n", This
, pEnum
);
5271 static HRESULT WINAPI
GraphConfig_RemoveFilterFromCache(IGraphConfig
*iface
,
5272 IBaseFilter
* pFilter
)
5274 ICOM_THIS_MULTI(IFilterGraphImpl
, IGraphConfig_vtbl
, iface
);
5276 FIXME("(%p)->(%p): stub!\n", This
, pFilter
);
5281 static HRESULT WINAPI
GraphConfig_GetStartTime(IGraphConfig
*iface
,
5282 REFERENCE_TIME
* prtStart
)
5284 ICOM_THIS_MULTI(IFilterGraphImpl
, IGraphConfig_vtbl
, iface
);
5286 FIXME("(%p)->(%p): stub!\n", This
, prtStart
);
5291 static HRESULT WINAPI
GraphConfig_PushThroughData(IGraphConfig
*iface
,
5293 IPinConnection
* pConnection
,
5296 ICOM_THIS_MULTI(IFilterGraphImpl
, IGraphConfig_vtbl
, iface
);
5298 FIXME("(%p)->(%p, %p, %p): stub!\n", This
, pOutputPin
, pConnection
, hEventAbort
);
5303 static HRESULT WINAPI
GraphConfig_SetFilterFlags(IGraphConfig
*iface
,
5304 IBaseFilter
* pFilter
,
5307 ICOM_THIS_MULTI(IFilterGraphImpl
, IGraphConfig_vtbl
, iface
);
5309 FIXME("(%p)->(%p, %x): stub!\n", This
, pFilter
, dwFlags
);
5314 static HRESULT WINAPI
GraphConfig_GetFilterFlags(IGraphConfig
*iface
,
5315 IBaseFilter
* pFilter
,
5318 ICOM_THIS_MULTI(IFilterGraphImpl
, IGraphConfig_vtbl
, iface
);
5320 FIXME("(%p)->(%p, %p): stub!\n", This
, pFilter
, dwFlags
);
5325 static HRESULT WINAPI
GraphConfig_RemoveFilterEx(IGraphConfig
*iface
,
5326 IBaseFilter
* pFilter
,
5329 ICOM_THIS_MULTI(IFilterGraphImpl
, IGraphConfig_vtbl
, iface
);
5331 FIXME("(%p)->(%p, %x): stub!\n", This
, pFilter
, dwFlags
);
5336 static const IGraphConfigVtbl IGraphConfig_VTable
=
5338 GraphConfig_QueryInterface
,
5340 GraphConfig_Release
,
5341 GraphConfig_Reconnect
,
5342 GraphConfig_Reconfigure
,
5343 GraphConfig_AddFilterToCache
,
5344 GraphConfig_EnumCacheFilter
,
5345 GraphConfig_RemoveFilterFromCache
,
5346 GraphConfig_GetStartTime
,
5347 GraphConfig_PushThroughData
,
5348 GraphConfig_SetFilterFlags
,
5349 GraphConfig_GetFilterFlags
,
5350 GraphConfig_RemoveFilterEx
5353 static const IUnknownVtbl IInner_VTable
=
5355 FilterGraphInner_QueryInterface
,
5356 FilterGraphInner_AddRef
,
5357 FilterGraphInner_Release
5360 static HRESULT
Filtergraph_QueryInterface(IFilterGraphImpl
*This
,
5363 if (This
->bAggregatable
)
5364 This
->bUnkOuterValid
= TRUE
;
5366 if (This
->pUnkOuter
)
5368 if (This
->bAggregatable
)
5369 return IUnknown_QueryInterface(This
->pUnkOuter
, riid
, ppv
);
5371 if (IsEqualIID(riid
, &IID_IUnknown
))
5375 IUnknown_AddRef((IUnknown
*)&(This
->IInner_vtbl
));
5376 hr
= IUnknown_QueryInterface((IUnknown
*)&(This
->IInner_vtbl
), riid
, ppv
);
5377 IUnknown_Release((IUnknown
*)&(This
->IInner_vtbl
));
5378 This
->bAggregatable
= TRUE
;
5383 return E_NOINTERFACE
;
5386 return IUnknown_QueryInterface((IUnknown
*)&(This
->IInner_vtbl
), riid
, ppv
);
5389 static ULONG
Filtergraph_AddRef(IFilterGraphImpl
*This
) {
5390 if (This
->pUnkOuter
&& This
->bUnkOuterValid
)
5391 return IUnknown_AddRef(This
->pUnkOuter
);
5392 return IUnknown_AddRef((IUnknown
*)&(This
->IInner_vtbl
));
5395 static ULONG
Filtergraph_Release(IFilterGraphImpl
*This
) {
5396 if (This
->pUnkOuter
&& This
->bUnkOuterValid
)
5397 return IUnknown_Release(This
->pUnkOuter
);
5398 return IUnknown_Release((IUnknown
*)&(This
->IInner_vtbl
));
5401 /* This is the only function that actually creates a FilterGraph class... */
5402 HRESULT
FilterGraph_create(IUnknown
*pUnkOuter
, LPVOID
*ppObj
)
5404 IFilterGraphImpl
*fimpl
;
5407 TRACE("(%p,%p)\n", pUnkOuter
, ppObj
);
5411 fimpl
= CoTaskMemAlloc(sizeof(*fimpl
));
5412 fimpl
->pUnkOuter
= pUnkOuter
;
5413 fimpl
->bUnkOuterValid
= FALSE
;
5414 fimpl
->bAggregatable
= FALSE
;
5415 fimpl
->IInner_vtbl
= &IInner_VTable
;
5416 fimpl
->IFilterGraph2_vtbl
= &IFilterGraph2_VTable
;
5417 fimpl
->IMediaControl_vtbl
= &IMediaControl_VTable
;
5418 fimpl
->IMediaSeeking_vtbl
= &IMediaSeeking_VTable
;
5419 fimpl
->IBasicAudio_vtbl
= &IBasicAudio_VTable
;
5420 fimpl
->IBasicVideo_vtbl
= &IBasicVideo_VTable
;
5421 fimpl
->IVideoWindow_vtbl
= &IVideoWindow_VTable
;
5422 fimpl
->IMediaEventEx_vtbl
= &IMediaEventEx_VTable
;
5423 fimpl
->IMediaFilter_vtbl
= &IMediaFilter_VTable
;
5424 fimpl
->IMediaEventSink_vtbl
= &IMediaEventSink_VTable
;
5425 fimpl
->IGraphConfig_vtbl
= &IGraphConfig_VTable
;
5426 fimpl
->IMediaPosition_vtbl
= &IMediaPosition_VTable
;
5428 fimpl
->ppFiltersInGraph
= NULL
;
5429 fimpl
->pFilterNames
= NULL
;
5430 fimpl
->nFilters
= 0;
5431 fimpl
->filterCapacity
= 0;
5432 fimpl
->nameIndex
= 1;
5433 fimpl
->refClock
= NULL
;
5434 fimpl
->hEventCompletion
= CreateEventW(0, TRUE
, FALSE
, 0);
5435 fimpl
->HandleEcComplete
= TRUE
;
5436 fimpl
->HandleEcRepaint
= TRUE
;
5437 fimpl
->HandleEcClockChanged
= TRUE
;
5438 fimpl
->notif
.hWnd
= 0;
5439 fimpl
->notif
.disabled
= FALSE
;
5440 fimpl
->nRenderers
= 0;
5441 fimpl
->EcCompleteCount
= 0;
5442 fimpl
->state
= State_Stopped
;
5443 EventsQueue_Init(&fimpl
->evqueue
);
5444 InitializeCriticalSection(&fimpl
->cs
);
5445 fimpl
->cs
.DebugInfo
->Spare
[0] = (DWORD_PTR
)(__FILE__
": IFilterGraphImpl.cs");
5446 fimpl
->nItfCacheEntries
= 0;
5447 memcpy(&fimpl
->timeformatseek
, &TIME_FORMAT_MEDIA_TIME
, sizeof(GUID
));
5448 fimpl
->start_time
= fimpl
->position
= 0;
5449 fimpl
->stop_position
= -1;
5450 fimpl
->punkFilterMapper2
= NULL
;
5451 fimpl
->recursioncount
= 0;
5453 /* create Filtermapper aggregated. */
5454 hr
= CoCreateInstance(&CLSID_FilterMapper2
, pUnkOuter
? pUnkOuter
: (IUnknown
*)&fimpl
->IInner_vtbl
, CLSCTX_INPROC_SERVER
,
5455 &IID_IUnknown
, (LPVOID
*)&fimpl
->punkFilterMapper2
);
5457 if (SUCCEEDED(hr
)) {
5458 hr
= IUnknown_QueryInterface(fimpl
->punkFilterMapper2
, &IID_IFilterMapper2
, (LPVOID
*)&fimpl
->pFilterMapper2
);
5461 if (SUCCEEDED(hr
)) {
5462 /* Release controlling IUnknown - compensate refcount increase from caching IFilterMapper2 interface. */
5463 if (pUnkOuter
) IUnknown_Release(pUnkOuter
);
5464 else IUnknown_Release((IUnknown
*)&fimpl
->IInner_vtbl
);
5468 ERR("Unable to create filter mapper (%x)\n", hr
);
5469 if (fimpl
->punkFilterMapper2
) IUnknown_Release(fimpl
->punkFilterMapper2
);
5470 CloseHandle(fimpl
->hEventCompletion
);
5471 EventsQueue_Destroy(&fimpl
->evqueue
);
5472 fimpl
->cs
.DebugInfo
->Spare
[0] = 0;
5473 DeleteCriticalSection(&fimpl
->cs
);
5474 CoTaskMemFree(fimpl
);
5477 IFilterGraph2_SetDefaultSyncSource((IFilterGraph2
*)fimpl
);
5483 HRESULT
FilterGraphNoThread_create(IUnknown
*pUnkOuter
, LPVOID
*ppObj
)
5485 FIXME("CLSID_FilterGraphNoThread partially implemented - Forwarding to CLSID_FilterGraph\n");
5486 return FilterGraph_create(pUnkOuter
, ppObj
);