blob: ed8f24eec6944efebbe5f772bf64c669fe9e86bf [file] [log] [blame]
Christian Costaf096fa32004-08-24 02:28:35 +00001/*
2 * Video Renderer (Fullscreen and Windowed using Direct Draw)
3 *
4 * Copyright 2004 Christian Costa
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
Jonathan Ernst360a3f92006-05-18 14:49:52 +020018 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
Christian Costaf096fa32004-08-24 02:28:35 +000019 */
20
21#include "config.h"
22
23#define NONAMELESSSTRUCT
24#define NONAMELESSUNION
25#include "quartz_private.h"
26#include "control_private.h"
27#include "pin.h"
28
29#include "uuids.h"
Christian Costaf096fa32004-08-24 02:28:35 +000030#include "vfwmsgs.h"
31#include "amvideo.h"
Christian Costaf096fa32004-08-24 02:28:35 +000032#include "windef.h"
33#include "winbase.h"
34#include "dshow.h"
Christian Costa7dea79c2005-03-02 10:12:12 +000035#include "evcode.h"
Christian Costaf096fa32004-08-24 02:28:35 +000036#include "strmif.h"
37#include "ddraw.h"
Maarten Lankhorst3e9cee02008-04-11 15:10:19 -070038#include "dvdmedia.h"
Christian Costaf096fa32004-08-24 02:28:35 +000039
Francois Gougeta516f272008-07-26 19:12:32 +020040#include <assert.h>
Christian Costaf096fa32004-08-24 02:28:35 +000041#include "wine/unicode.h"
42#include "wine/debug.h"
43
44WINE_DEFAULT_DEBUG_CHANNEL(quartz);
45
Christian Costaacb2ff22005-06-13 11:37:55 +000046static BOOL wnd_class_registered = FALSE;
47
Christian Costaf096fa32004-08-24 02:28:35 +000048static const WCHAR wcsInputPinName[] = {'i','n','p','u','t',' ','p','i','n',0};
49
50static const IBaseFilterVtbl VideoRenderer_Vtbl;
Lei Zhang932cc2d2007-12-13 03:16:27 -080051static const IUnknownVtbl IInner_VTable;
Dmitry Timoshkoveba47f12005-06-06 19:50:35 +000052static const IBasicVideoVtbl IBasicVideo_VTable;
53static const IVideoWindowVtbl IVideoWindow_VTable;
Christian Costaf096fa32004-08-24 02:28:35 +000054static const IPinVtbl VideoRenderer_InputPin_Vtbl;
55
56typedef struct VideoRendererImpl
57{
58 const IBaseFilterVtbl * lpVtbl;
Dmitry Timoshkoveba47f12005-06-06 19:50:35 +000059 const IBasicVideoVtbl * IBasicVideo_vtbl;
60 const IVideoWindowVtbl * IVideoWindow_vtbl;
Lei Zhang932cc2d2007-12-13 03:16:27 -080061 const IUnknownVtbl * IInner_vtbl;
Christian Costaf096fa32004-08-24 02:28:35 +000062
Mike McCormack0791d062005-07-12 19:21:36 +000063 LONG refCount;
Christian Costaf096fa32004-08-24 02:28:35 +000064 CRITICAL_SECTION csFilter;
65 FILTER_STATE state;
66 REFERENCE_TIME rtStreamStart;
67 IReferenceClock * pClock;
68 FILTER_INFO filterInfo;
69
Maarten Lankhorst79349512008-04-25 14:25:49 -070070 InputPin *pInputPin;
Christian Costaf096fa32004-08-24 02:28:35 +000071
Christian Costaacb2ff22005-06-13 11:37:55 +000072 BOOL init;
73 HANDLE hThread;
Maarten Lankhorst9985f2e2008-07-04 01:33:04 -070074 HANDLE blocked;
75
Christian Costaacb2ff22005-06-13 11:37:55 +000076 DWORD ThreadID;
77 HANDLE hEvent;
78 BOOL ThreadResult;
79 HWND hWnd;
80 HWND hWndMsgDrain;
81 BOOL AutoShow;
82 RECT SourceRect;
83 RECT DestRect;
84 RECT WindowPos;
85 long VideoWidth;
86 long VideoHeight;
Lei Zhang932cc2d2007-12-13 03:16:27 -080087 IUnknown * pUnkOuter;
88 BOOL bUnkOuterValid;
89 BOOL bAggregatable;
Maarten Lankhorst37847b02008-04-28 15:00:51 -070090 REFERENCE_TIME rtLastStop;
Maarten Lankhorst2eb66372008-06-10 18:40:09 +020091 MediaSeekingImpl mediaSeeking;
Maarten Lankhorstdae09d02008-06-10 18:45:25 +020092
93 /* During pause we can hold a single sample, for use in GetCurrentImage */
94 IMediaSample *sample_held;
Christian Costaf096fa32004-08-24 02:28:35 +000095} VideoRendererImpl;
96
Christian Costaacb2ff22005-06-13 11:37:55 +000097static LRESULT CALLBACK VideoWndProcA(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
98{
Alexandre Julliard8c335282009-01-08 17:30:57 +010099 VideoRendererImpl* pVideoRenderer = (VideoRendererImpl*)GetWindowLongPtrW(hwnd, 0);
Christian Costaacb2ff22005-06-13 11:37:55 +0000100 LPRECT lprect = (LPRECT)lParam;
101
102 if (pVideoRenderer && pVideoRenderer->hWndMsgDrain)
103 {
104 switch(uMsg)
105 {
106 case WM_KEYDOWN:
107 case WM_KEYUP:
108 case WM_LBUTTONDBLCLK:
109 case WM_LBUTTONDOWN:
110 case WM_LBUTTONUP:
111 case WM_MBUTTONDBLCLK:
112 case WM_MBUTTONDOWN:
113 case WM_MBUTTONUP:
114 case WM_MOUSEACTIVATE:
115 case WM_MOUSEMOVE:
116 case WM_NCLBUTTONDBLCLK:
117 case WM_NCLBUTTONDOWN:
118 case WM_NCLBUTTONUP:
119 case WM_NCMBUTTONDBLCLK:
120 case WM_NCMBUTTONDOWN:
121 case WM_NCMBUTTONUP:
122 case WM_NCMOUSEMOVE:
123 case WM_NCRBUTTONDBLCLK:
124 case WM_NCRBUTTONDOWN:
125 case WM_NCRBUTTONUP:
126 case WM_RBUTTONDBLCLK:
127 case WM_RBUTTONDOWN:
128 case WM_RBUTTONUP:
129 PostMessageA(pVideoRenderer->hWndMsgDrain, uMsg, wParam, lParam);
130 break;
131 default:
132 break;
133 }
134 }
135
136 switch(uMsg)
137 {
138 case WM_SIZING:
Hans Leidekkercfbb8592006-10-12 20:57:23 +0200139 /* TRACE("WM_SIZING %d %d %d %d\n", lprect->left, lprect->top, lprect->right, lprect->bottom); */
Christian Costaacb2ff22005-06-13 11:37:55 +0000140 SetWindowPos(hwnd, NULL, lprect->left, lprect->top, lprect->right - lprect->left, lprect->bottom - lprect->top, SWP_NOZORDER);
141 GetClientRect(hwnd, &pVideoRenderer->DestRect);
Alex Villacís Lassofb8df8e2007-06-19 11:47:32 -0500142 TRACE("WM_SIZING: DestRect=(%d,%d),(%d,%d)\n",
143 pVideoRenderer->DestRect.left,
144 pVideoRenderer->DestRect.top,
145 pVideoRenderer->DestRect.right - pVideoRenderer->DestRect.left,
146 pVideoRenderer->DestRect.bottom - pVideoRenderer->DestRect.top);
147 return TRUE;
148 case WM_SIZE:
149 TRACE("WM_SIZE %d %d\n", LOWORD(lParam), HIWORD(lParam));
150 GetClientRect(hwnd, &pVideoRenderer->DestRect);
151 TRACE("WM_SIZING: DestRect=(%d,%d),(%d,%d)\n",
152 pVideoRenderer->DestRect.left,
153 pVideoRenderer->DestRect.top,
154 pVideoRenderer->DestRect.right - pVideoRenderer->DestRect.left,
155 pVideoRenderer->DestRect.bottom - pVideoRenderer->DestRect.top);
Christian Costaacb2ff22005-06-13 11:37:55 +0000156 return TRUE;
157 default:
158 return DefWindowProcA(hwnd, uMsg, wParam, lParam);
159 }
160 return 0;
161}
162
163static BOOL CreateRenderingWindow(VideoRendererImpl* This)
164{
165 WNDCLASSA winclass;
166
167 TRACE("(%p)->()\n", This);
168
169 winclass.style = 0;
170 winclass.lpfnWndProc = VideoWndProcA;
171 winclass.cbClsExtra = 0;
172 winclass.cbWndExtra = sizeof(VideoRendererImpl*);
173 winclass.hInstance = NULL;
174 winclass.hIcon = NULL;
175 winclass.hCursor = NULL;
Christian Costab82d94e2005-10-10 10:44:54 +0000176 winclass.hbrBackground = GetStockObject(BLACK_BRUSH);
Christian Costaacb2ff22005-06-13 11:37:55 +0000177 winclass.lpszMenuName = NULL;
178 winclass.lpszClassName = "Wine ActiveMovie Class";
179
180 if (!wnd_class_registered)
181 {
182 if (!RegisterClassA(&winclass))
183 {
Francois Gouget4fb03d92007-01-05 13:05:20 +0100184 ERR("Unable to register window %u\n", GetLastError());
Christian Costaacb2ff22005-06-13 11:37:55 +0000185 return FALSE;
186 }
187 wnd_class_registered = TRUE;
188 }
189
190 This->hWnd = CreateWindowExA(0, "Wine ActiveMovie Class", "Wine ActiveMovie Window", WS_SIZEBOX,
191 CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL,
192 NULL, NULL, NULL);
193
194 if (!This->hWnd)
195 {
196 ERR("Unable to create window\n");
197 return FALSE;
198 }
199
Alexandre Julliard8c335282009-01-08 17:30:57 +0100200 SetWindowLongPtrW(This->hWnd, 0, (LONG_PTR)This);
Christian Costaacb2ff22005-06-13 11:37:55 +0000201
202 return TRUE;
203}
204
205static DWORD WINAPI MessageLoop(LPVOID lpParameter)
206{
Michael Stefaniuccc7fc4a2009-01-29 11:14:55 +0100207 VideoRendererImpl* This = lpParameter;
Christian Costaacb2ff22005-06-13 11:37:55 +0000208 MSG msg;
209 BOOL fGotMessage;
210
211 TRACE("Starting message loop\n");
212
213 if (!CreateRenderingWindow(This))
214 {
215 This->ThreadResult = FALSE;
216 SetEvent(This->hEvent);
217 return 0;
218 }
219
220 This->ThreadResult = TRUE;
221 SetEvent(This->hEvent);
222
Francois Gouget77065602005-06-17 20:55:27 +0000223 while ((fGotMessage = GetMessageA(&msg, NULL, 0, 0)) != 0 && fGotMessage != -1)
Christian Costaacb2ff22005-06-13 11:37:55 +0000224 {
225 TranslateMessage(&msg);
226 DispatchMessageA(&msg);
227 }
228
229 TRACE("End of message loop\n");
230
231 return msg.wParam;
232}
233
234static BOOL CreateRenderingSubsystem(VideoRendererImpl* This)
235{
Maarten Lankhorst9985f2e2008-07-04 01:33:04 -0700236 This->hEvent = CreateEventW(NULL, TRUE, FALSE, NULL);
Christian Costaacb2ff22005-06-13 11:37:55 +0000237 if (!This->hEvent)
238 return FALSE;
239
Michael Stefaniuccc7fc4a2009-01-29 11:14:55 +0100240 This->hThread = CreateThread(NULL, 0, MessageLoop, This, 0, &This->ThreadID);
Christian Costaacb2ff22005-06-13 11:37:55 +0000241 if (!This->hThread)
242 {
243 CloseHandle(This->hEvent);
244 return FALSE;
245 }
246
247 WaitForSingleObject(This->hEvent, INFINITE);
Christian Costaacb2ff22005-06-13 11:37:55 +0000248
249 if (!This->ThreadResult)
250 {
Maarten Lankhorst9985f2e2008-07-04 01:33:04 -0700251 CloseHandle(This->hEvent);
Christian Costaacb2ff22005-06-13 11:37:55 +0000252 CloseHandle(This->hThread);
253 return FALSE;
254 }
255
256 return TRUE;
257}
258
Christian Costaf096fa32004-08-24 02:28:35 +0000259static DWORD VideoRenderer_SendSampleData(VideoRendererImpl* This, LPBYTE data, DWORD size)
260{
Christian Costaf096fa32004-08-24 02:28:35 +0000261 AM_MEDIA_TYPE amt;
262 HRESULT hr = S_OK;
Maarten Lankhorst79349512008-04-25 14:25:49 -0700263 DDSURFACEDESC sdesc;
Christian Costaacb2ff22005-06-13 11:37:55 +0000264 HDC hDC;
Maarten Lankhorst3e9cee02008-04-11 15:10:19 -0700265 BITMAPINFOHEADER *bmiHeader;
Christian Costaf096fa32004-08-24 02:28:35 +0000266
Christian Costac83e4f12008-12-29 12:00:10 +0100267 TRACE("(%p)->(%p, %d)\n", This, data, size);
Christian Costaf096fa32004-08-24 02:28:35 +0000268
Maarten Lankhorst79349512008-04-25 14:25:49 -0700269 sdesc.dwSize = sizeof(sdesc);
270 hr = IPin_ConnectionMediaType((IPin *)This->pInputPin, &amt);
Christian Costaf096fa32004-08-24 02:28:35 +0000271 if (FAILED(hr)) {
Christian Costaacb2ff22005-06-13 11:37:55 +0000272 ERR("Unable to retrieve media type\n");
273 return hr;
Christian Costaf096fa32004-08-24 02:28:35 +0000274 }
Christian Costaf096fa32004-08-24 02:28:35 +0000275
Maarten Lankhorst3e9cee02008-04-11 15:10:19 -0700276 if (IsEqualIID(&amt.formattype, &FORMAT_VideoInfo))
277 {
278 bmiHeader = &((VIDEOINFOHEADER *)amt.pbFormat)->bmiHeader;
279 }
280 else if (IsEqualIID(&amt.formattype, &FORMAT_VideoInfo2))
281 {
282 bmiHeader = &((VIDEOINFOHEADER2 *)amt.pbFormat)->bmiHeader;
283 }
284 else
285 {
286 FIXME("Unknown type %s\n", debugstr_guid(&amt.subtype));
287 return VFW_E_RUNTIME_ERROR;
288 }
Christian Costaf096fa32004-08-24 02:28:35 +0000289
Maarten Lankhorst3e9cee02008-04-11 15:10:19 -0700290
291 TRACE("biSize = %d\n", bmiHeader->biSize);
292 TRACE("biWidth = %d\n", bmiHeader->biWidth);
293 TRACE("biHeight = %d\n", bmiHeader->biHeight);
294 TRACE("biPlanes = %d\n", bmiHeader->biPlanes);
295 TRACE("biBitCount = %d\n", bmiHeader->biBitCount);
296 TRACE("biCompression = %s\n", debugstr_an((LPSTR)&(bmiHeader->biCompression), 4));
297 TRACE("biSizeImage = %d\n", bmiHeader->biSizeImage);
298
Christian Costaacb2ff22005-06-13 11:37:55 +0000299 if (!This->init)
Christian Costaf096fa32004-08-24 02:28:35 +0000300 {
Henri Verbeet166db1e2009-02-19 08:53:50 +0100301 DWORD style = GetWindowLongW(This->hWnd, GWL_STYLE);
302 DWORD style_ex = GetWindowLongW(This->hWnd, GWL_EXSTYLE);
303
Maarten Lankhorst3e9cee02008-04-11 15:10:19 -0700304 if (!This->WindowPos.right || !This->WindowPos.bottom)
305 This->WindowPos = This->SourceRect;
306
Henri Verbeet166db1e2009-02-19 08:53:50 +0100307 AdjustWindowRectEx(&This->WindowPos, style, TRUE, style_ex);
308
Alex Villacís Lassofb8df8e2007-06-19 11:47:32 -0500309 TRACE("WindowPos: %d %d %d %d\n", This->WindowPos.left, This->WindowPos.top, This->WindowPos.right, This->WindowPos.bottom);
310 SetWindowPos(This->hWnd, NULL,
311 This->WindowPos.left,
312 This->WindowPos.top,
313 This->WindowPos.right - This->WindowPos.left,
314 This->WindowPos.bottom - This->WindowPos.top,
315 SWP_NOZORDER|SWP_NOMOVE);
Maarten Lankhorst3e9cee02008-04-11 15:10:19 -0700316
Christian Costaacb2ff22005-06-13 11:37:55 +0000317 GetClientRect(This->hWnd, &This->DestRect);
Maarten Lankhorst3e9cee02008-04-11 15:10:19 -0700318 This->init = TRUE;
Christian Costaf096fa32004-08-24 02:28:35 +0000319 }
320
Christian Costaacb2ff22005-06-13 11:37:55 +0000321 hDC = GetDC(This->hWnd);
322
323 if (!hDC) {
324 ERR("Cannot get DC from window!\n");
325 return E_FAIL;
Christian Costaf096fa32004-08-24 02:28:35 +0000326 }
Christian Costaacb2ff22005-06-13 11:37:55 +0000327
Hans Leidekkercfbb8592006-10-12 20:57:23 +0200328 TRACE("Src Rect: %d %d %d %d\n", This->SourceRect.left, This->SourceRect.top, This->SourceRect.right, This->SourceRect.bottom);
329 TRACE("Dst Rect: %d %d %d %d\n", This->DestRect.left, This->DestRect.top, This->DestRect.right, This->DestRect.bottom);
Christian Costaacb2ff22005-06-13 11:37:55 +0000330
331 StretchDIBits(hDC, This->DestRect.left, This->DestRect.top, This->DestRect.right -This->DestRect.left,
332 This->DestRect.bottom - This->DestRect.top, This->SourceRect.left, This->SourceRect.top,
333 This->SourceRect.right - This->SourceRect.left, This->SourceRect.bottom - This->SourceRect.top,
Maarten Lankhorst3e9cee02008-04-11 15:10:19 -0700334 data, (BITMAPINFO *)bmiHeader, DIB_RGB_COLORS, SRCCOPY);
Christian Costaacb2ff22005-06-13 11:37:55 +0000335
336 ReleaseDC(This->hWnd, hDC);
Christian Costaacb2ff22005-06-13 11:37:55 +0000337 if (This->AutoShow)
338 ShowWindow(This->hWnd, SW_SHOW);
339
Christian Costaf096fa32004-08-24 02:28:35 +0000340 return S_OK;
341}
342
343static HRESULT VideoRenderer_Sample(LPVOID iface, IMediaSample * pSample)
344{
Michael Stefaniuccc7fc4a2009-01-29 11:14:55 +0100345 VideoRendererImpl *This = iface;
Christian Costaf096fa32004-08-24 02:28:35 +0000346 LPBYTE pbSrcStream = NULL;
347 long cbSrcStream = 0;
348 REFERENCE_TIME tStart, tStop;
349 HRESULT hr;
Christian Costa50fda762008-12-02 20:29:48 +0100350
Christian Costac83e4f12008-12-29 12:00:10 +0100351 TRACE("(%p)->(%p)\n", iface, pSample);
352
Maarten Lankhorst992fb022008-07-04 16:59:22 -0700353 EnterCriticalSection(&This->csFilter);
Christian Costa50fda762008-12-02 20:29:48 +0100354
Maarten Lankhorst992fb022008-07-04 16:59:22 -0700355 if (This->pInputPin->flushing || This->pInputPin->end_of_stream)
Christian Costa50fda762008-12-02 20:29:48 +0100356 {
357 LeaveCriticalSection(&This->csFilter);
358 return S_FALSE;
359 }
Christian Costaf096fa32004-08-24 02:28:35 +0000360
Maarten Lankhorst3dc83842008-04-16 14:24:34 -0700361 if (This->state == State_Stopped)
Maarten Lankhorst992fb022008-07-04 16:59:22 -0700362 {
363 LeaveCriticalSection(&This->csFilter);
Maarten Lankhorst28c7b232008-07-02 20:09:33 -0700364 return VFW_E_WRONG_STATE;
Maarten Lankhorst992fb022008-07-04 16:59:22 -0700365 }
Maarten Lankhorst3dc83842008-04-16 14:24:34 -0700366
Maarten Lankhorst37847b02008-04-28 15:00:51 -0700367 hr = IMediaSample_GetTime(pSample, &tStart, &tStop);
368 if (FAILED(hr))
369 ERR("Cannot get sample time (%x)\n", hr);
370
371 if (This->rtLastStop != tStart)
372 {
373 if (IMediaSample_IsDiscontinuity(pSample) == S_FALSE)
374 ERR("Unexpected discontinuity: Last: %u.%03u, tStart: %u.%03u\n",
375 (DWORD)(This->rtLastStop / 10000000),
376 (DWORD)((This->rtLastStop / 10000)%1000),
377 (DWORD)(tStart / 10000000), (DWORD)((tStart / 10000)%1000));
378 This->rtLastStop = tStart;
379 }
380
Maarten Lankhorst458b09a2008-04-17 11:16:13 -0700381 /* Preroll means the sample isn't shown, this is used for key frames and things like that */
382 if (IMediaSample_IsPreroll(pSample) == S_OK)
Maarten Lankhorst37847b02008-04-28 15:00:51 -0700383 {
384 This->rtLastStop = tStop;
Maarten Lankhorst992fb022008-07-04 16:59:22 -0700385 LeaveCriticalSection(&This->csFilter);
Maarten Lankhorst458b09a2008-04-17 11:16:13 -0700386 return S_OK;
Maarten Lankhorst37847b02008-04-28 15:00:51 -0700387 }
Maarten Lankhorst458b09a2008-04-17 11:16:13 -0700388
Christian Costaf096fa32004-08-24 02:28:35 +0000389 hr = IMediaSample_GetPointer(pSample, &pbSrcStream);
390 if (FAILED(hr))
391 {
Hans Leidekkercfbb8592006-10-12 20:57:23 +0200392 ERR("Cannot get pointer to sample data (%x)\n", hr);
Maarten Lankhorst992fb022008-07-04 16:59:22 -0700393 LeaveCriticalSection(&This->csFilter);
Christian Costaacb2ff22005-06-13 11:37:55 +0000394 return hr;
Christian Costaf096fa32004-08-24 02:28:35 +0000395 }
396
Christian Costaf096fa32004-08-24 02:28:35 +0000397 cbSrcStream = IMediaSample_GetActualDataLength(pSample);
398
399 TRACE("val %p %ld\n", pbSrcStream, cbSrcStream);
400
401#if 0 /* For debugging purpose */
402 {
403 int i;
404 for(i = 0; i < cbSrcStream; i++)
405 {
Christian Costaacb2ff22005-06-13 11:37:55 +0000406 if ((i!=0) && !(i%16))
Alexandre Julliard9f859692005-09-25 15:23:21 +0000407 TRACE("\n");
408 TRACE("%02x ", pbSrcStream[i]);
Christian Costaf096fa32004-08-24 02:28:35 +0000409 }
Alexandre Julliard9f859692005-09-25 15:23:21 +0000410 TRACE("\n");
Christian Costaf096fa32004-08-24 02:28:35 +0000411 }
412#endif
Maarten Lankhorst79349512008-04-25 14:25:49 -0700413
Maarten Lankhorst9985f2e2008-07-04 01:33:04 -0700414 SetEvent(This->hEvent);
Maarten Lankhorstdae09d02008-06-10 18:45:25 +0200415 if (This->state == State_Paused)
416 {
Maarten Lankhorstdae09d02008-06-10 18:45:25 +0200417 This->sample_held = pSample;
Maarten Lankhorst9985f2e2008-07-04 01:33:04 -0700418 LeaveCriticalSection(&This->csFilter);
419 WaitForSingleObject(This->blocked, INFINITE);
420 EnterCriticalSection(&This->csFilter);
421 This->sample_held = NULL;
422 if (This->state == State_Paused)
Maarten Lankhorst992fb022008-07-04 16:59:22 -0700423 {
Maarten Lankhorst9985f2e2008-07-04 01:33:04 -0700424 /* Flushing */
Maarten Lankhorst992fb022008-07-04 16:59:22 -0700425 LeaveCriticalSection(&This->csFilter);
Maarten Lankhorst9985f2e2008-07-04 01:33:04 -0700426 return S_OK;
Maarten Lankhorst992fb022008-07-04 16:59:22 -0700427 }
Maarten Lankhorst9985f2e2008-07-04 01:33:04 -0700428 if (This->state == State_Stopped)
Maarten Lankhorst992fb022008-07-04 16:59:22 -0700429 {
430 LeaveCriticalSection(&This->csFilter);
Maarten Lankhorst9985f2e2008-07-04 01:33:04 -0700431 return VFW_E_WRONG_STATE;
Maarten Lankhorst992fb022008-07-04 16:59:22 -0700432 }
Maarten Lankhorstdae09d02008-06-10 18:45:25 +0200433 }
434
Maarten Lankhorst37847b02008-04-28 15:00:51 -0700435 if (This->pClock && This->state == State_Running)
436 {
437 REFERENCE_TIME time, trefstart, trefstop;
438 LONG delta;
439
440 /* Perhaps I <SHOULD> use the reference clock AdviseTime function here
441 * I'm not going to! When I tried, it seemed to generate lag and
442 * it caused instability.
443 */
444 IReferenceClock_GetTime(This->pClock, &time);
445
446 trefstart = This->rtStreamStart;
447 trefstop = (REFERENCE_TIME)((double)(tStop - tStart) / This->pInputPin->dRate) + This->rtStreamStart;
448 delta = (LONG)((trefstart-time)/10000);
449 This->rtStreamStart = trefstop;
450 This->rtLastStop = tStop;
451
452 if (delta > 0)
453 {
454 TRACE("Sleeping for %u ms\n", delta);
455 Sleep(delta);
456 }
457 else if (time > trefstop)
458 {
Alexandre Julliardaa682582008-06-30 12:50:07 +0200459 TRACE("Dropping sample: Time: %u.%03u ms trefstop: %u.%03u ms!\n",
460 (DWORD)(time / 10000000), (DWORD)((time / 10000)%1000),
461 (DWORD)(trefstop / 10000000), (DWORD)((trefstop / 10000)%1000) );
Maarten Lankhorst37847b02008-04-28 15:00:51 -0700462 This->rtLastStop = tStop;
Maarten Lankhorst992fb022008-07-04 16:59:22 -0700463 LeaveCriticalSection(&This->csFilter);
Maarten Lankhorst37847b02008-04-28 15:00:51 -0700464 return S_OK;
465 }
466 }
467 This->rtLastStop = tStop;
468
Christian Costaf096fa32004-08-24 02:28:35 +0000469 VideoRenderer_SendSampleData(This, pbSrcStream, cbSrcStream);
470
Maarten Lankhorst992fb022008-07-04 16:59:22 -0700471 LeaveCriticalSection(&This->csFilter);
Christian Costaf096fa32004-08-24 02:28:35 +0000472 return S_OK;
473}
474
475static HRESULT VideoRenderer_QueryAccept(LPVOID iface, const AM_MEDIA_TYPE * pmt)
476{
Christian Costab82d94e2005-10-10 10:44:54 +0000477 if (!IsEqualIID(&pmt->majortype, &MEDIATYPE_Video))
478 return S_FALSE;
479
480 if (IsEqualIID(&pmt->subtype, &MEDIASUBTYPE_RGB32) ||
481 IsEqualIID(&pmt->subtype, &MEDIASUBTYPE_RGB24) ||
482 IsEqualIID(&pmt->subtype, &MEDIASUBTYPE_RGB565) ||
483 IsEqualIID(&pmt->subtype, &MEDIASUBTYPE_RGB8))
Christian Costaacb2ff22005-06-13 11:37:55 +0000484 {
Michael Stefaniuccc7fc4a2009-01-29 11:14:55 +0100485 VideoRendererImpl* This = iface;
Christian Costab82d94e2005-10-10 10:44:54 +0000486
Maarten Lankhorst3e9cee02008-04-11 15:10:19 -0700487 if (IsEqualIID(&pmt->formattype, &FORMAT_VideoInfo))
488 {
489 VIDEOINFOHEADER *format = (VIDEOINFOHEADER *)pmt->pbFormat;
490 This->SourceRect.left = 0;
491 This->SourceRect.top = 0;
492 This->SourceRect.right = This->VideoWidth = format->bmiHeader.biWidth;
493 This->SourceRect.bottom = This->VideoHeight = format->bmiHeader.biHeight;
494 }
495 else if (IsEqualIID(&pmt->formattype, &FORMAT_VideoInfo2))
496 {
497 VIDEOINFOHEADER2 *format2 = (VIDEOINFOHEADER2 *)pmt->pbFormat;
498
499 This->SourceRect.left = 0;
500 This->SourceRect.top = 0;
501 This->SourceRect.right = This->VideoWidth = format2->bmiHeader.biWidth;
502 This->SourceRect.bottom = This->VideoHeight = format2->bmiHeader.biHeight;
503 }
504 else
Christian Costab82d94e2005-10-10 10:44:54 +0000505 {
506 WARN("Format type %s not supported\n", debugstr_guid(&pmt->formattype));
507 return S_FALSE;
508 }
Christian Costaf096fa32004-08-24 02:28:35 +0000509 return S_OK;
Christian Costaacb2ff22005-06-13 11:37:55 +0000510 }
Christian Costaf096fa32004-08-24 02:28:35 +0000511 return S_FALSE;
512}
513
Maarten Lankhorst2eb66372008-06-10 18:40:09 +0200514static inline VideoRendererImpl *impl_from_IMediaSeeking( IMediaSeeking *iface )
515{
516 return (VideoRendererImpl *)((char*)iface - FIELD_OFFSET(VideoRendererImpl, mediaSeeking.lpVtbl));
517}
518
519static HRESULT WINAPI VideoRendererImpl_Seeking_QueryInterface(IMediaSeeking * iface, REFIID riid, LPVOID * ppv)
520{
521 VideoRendererImpl *This = impl_from_IMediaSeeking(iface);
522
523 return IUnknown_QueryInterface((IUnknown *)This, riid, ppv);
524}
525
526static ULONG WINAPI VideoRendererImpl_Seeking_AddRef(IMediaSeeking * iface)
527{
528 VideoRendererImpl *This = impl_from_IMediaSeeking(iface);
529
530 return IUnknown_AddRef((IUnknown *)This);
531}
532
533static ULONG WINAPI VideoRendererImpl_Seeking_Release(IMediaSeeking * iface)
534{
535 VideoRendererImpl *This = impl_from_IMediaSeeking(iface);
536
537 return IUnknown_Release((IUnknown *)This);
538}
539
540static const IMediaSeekingVtbl VideoRendererImpl_Seeking_Vtbl =
541{
542 VideoRendererImpl_Seeking_QueryInterface,
543 VideoRendererImpl_Seeking_AddRef,
544 VideoRendererImpl_Seeking_Release,
545 MediaSeekingImpl_GetCapabilities,
546 MediaSeekingImpl_CheckCapabilities,
547 MediaSeekingImpl_IsFormatSupported,
548 MediaSeekingImpl_QueryPreferredFormat,
549 MediaSeekingImpl_GetTimeFormat,
550 MediaSeekingImpl_IsUsingTimeFormat,
551 MediaSeekingImpl_SetTimeFormat,
552 MediaSeekingImpl_GetDuration,
553 MediaSeekingImpl_GetStopPosition,
554 MediaSeekingImpl_GetCurrentPosition,
555 MediaSeekingImpl_ConvertTimeFormat,
556 MediaSeekingImpl_SetPositions,
557 MediaSeekingImpl_GetPositions,
558 MediaSeekingImpl_GetAvailable,
559 MediaSeekingImpl_SetRate,
560 MediaSeekingImpl_GetRate,
561 MediaSeekingImpl_GetPreroll
562};
563
564static HRESULT VideoRendererImpl_Change(IBaseFilter *iface)
565{
Christian Costac83e4f12008-12-29 12:00:10 +0100566 TRACE("(%p)->()\n", iface);
Maarten Lankhorst2eb66372008-06-10 18:40:09 +0200567 return S_OK;
568}
569
Christian Costaf096fa32004-08-24 02:28:35 +0000570HRESULT VideoRenderer_create(IUnknown * pUnkOuter, LPVOID * ppv)
571{
572 HRESULT hr;
573 PIN_INFO piInput;
574 VideoRendererImpl * pVideoRenderer;
575
576 TRACE("(%p, %p)\n", pUnkOuter, ppv);
577
578 *ppv = NULL;
579
Christian Costaf096fa32004-08-24 02:28:35 +0000580 pVideoRenderer = CoTaskMemAlloc(sizeof(VideoRendererImpl));
Lei Zhang932cc2d2007-12-13 03:16:27 -0800581 pVideoRenderer->pUnkOuter = pUnkOuter;
582 pVideoRenderer->bUnkOuterValid = FALSE;
583 pVideoRenderer->bAggregatable = FALSE;
584 pVideoRenderer->IInner_vtbl = &IInner_VTable;
Christian Costaf096fa32004-08-24 02:28:35 +0000585
586 pVideoRenderer->lpVtbl = &VideoRenderer_Vtbl;
587 pVideoRenderer->IBasicVideo_vtbl = &IBasicVideo_VTable;
588 pVideoRenderer->IVideoWindow_vtbl = &IVideoWindow_VTable;
589
590 pVideoRenderer->refCount = 1;
591 InitializeCriticalSection(&pVideoRenderer->csFilter);
Jan Zerebeckib5619e82007-03-10 22:10:20 +0100592 pVideoRenderer->csFilter.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": VideoRendererImpl.csFilter");
Christian Costaf096fa32004-08-24 02:28:35 +0000593 pVideoRenderer->state = State_Stopped;
594 pVideoRenderer->pClock = NULL;
595 pVideoRenderer->init = 0;
Christian Costaacb2ff22005-06-13 11:37:55 +0000596 pVideoRenderer->AutoShow = 1;
Maarten Lankhorst37847b02008-04-28 15:00:51 -0700597 pVideoRenderer->rtLastStop = -1;
Christian Costaf096fa32004-08-24 02:28:35 +0000598 ZeroMemory(&pVideoRenderer->filterInfo, sizeof(FILTER_INFO));
Maarten Lankhorst5026c252008-05-21 15:48:32 -0700599 ZeroMemory(&pVideoRenderer->SourceRect, sizeof(RECT));
600 ZeroMemory(&pVideoRenderer->DestRect, sizeof(RECT));
601 ZeroMemory(&pVideoRenderer->WindowPos, sizeof(RECT));
602 pVideoRenderer->hWndMsgDrain = NULL;
Christian Costaf096fa32004-08-24 02:28:35 +0000603
Christian Costaf096fa32004-08-24 02:28:35 +0000604 /* construct input pin */
605 piInput.dir = PINDIR_INPUT;
606 piInput.pFilter = (IBaseFilter *)pVideoRenderer;
Peter Berg Larsene732fc02005-03-28 14:17:51 +0000607 lstrcpynW(piInput.achName, wcsInputPinName, sizeof(piInput.achName) / sizeof(piInput.achName[0]));
Christian Costaf096fa32004-08-24 02:28:35 +0000608
Maarten Lankhorste8705402008-06-10 17:57:41 +0200609 hr = InputPin_Construct(&VideoRenderer_InputPin_Vtbl, &piInput, VideoRenderer_Sample, (LPVOID)pVideoRenderer, VideoRenderer_QueryAccept, NULL, &pVideoRenderer->csFilter, NULL, (IPin **)&pVideoRenderer->pInputPin);
Christian Costaf096fa32004-08-24 02:28:35 +0000610
611 if (SUCCEEDED(hr))
612 {
Maarten Lankhorst2eb66372008-06-10 18:40:09 +0200613 MediaSeekingImpl_Init((IBaseFilter*)pVideoRenderer, VideoRendererImpl_Change, VideoRendererImpl_Change, VideoRendererImpl_Change, &pVideoRenderer->mediaSeeking, &pVideoRenderer->csFilter);
614 pVideoRenderer->mediaSeeking.lpVtbl = &VideoRendererImpl_Seeking_Vtbl;
615
Maarten Lankhorstdae09d02008-06-10 18:45:25 +0200616 pVideoRenderer->sample_held = NULL;
Michael Stefaniuccc7fc4a2009-01-29 11:14:55 +0100617 *ppv = pVideoRenderer;
Christian Costaf096fa32004-08-24 02:28:35 +0000618 }
619 else
620 {
Jan Zerebeckib5619e82007-03-10 22:10:20 +0100621 pVideoRenderer->csFilter.DebugInfo->Spare[0] = 0;
Christian Costaf096fa32004-08-24 02:28:35 +0000622 DeleteCriticalSection(&pVideoRenderer->csFilter);
623 CoTaskMemFree(pVideoRenderer);
624 }
625
Christian Costaacb2ff22005-06-13 11:37:55 +0000626 if (!CreateRenderingSubsystem(pVideoRenderer))
627 return E_FAIL;
Maarten Lankhorst9985f2e2008-07-04 01:33:04 -0700628
629 pVideoRenderer->blocked = CreateEventW(NULL, FALSE, FALSE, NULL);
630 if (!pVideoRenderer->blocked)
631 {
632 hr = HRESULT_FROM_WIN32(GetLastError());
633 IUnknown_Release((IUnknown *)pVideoRenderer);
634 }
635
Christian Costaf096fa32004-08-24 02:28:35 +0000636 return hr;
637}
638
Lei Zhang97427242008-02-02 01:47:34 -0800639HRESULT VideoRendererDefault_create(IUnknown * pUnkOuter, LPVOID * ppv)
640{
Austin English313a85f2008-04-10 21:17:14 -0500641 /* TODO: Attempt to use the VMR-7 renderer instead when possible */
Lei Zhang97427242008-02-02 01:47:34 -0800642 return VideoRenderer_create(pUnkOuter, ppv);
643}
644
Lei Zhang63df94b2007-12-13 15:05:58 -0800645static HRESULT WINAPI VideoRendererInner_QueryInterface(IUnknown * iface, REFIID riid, LPVOID * ppv)
Christian Costaf096fa32004-08-24 02:28:35 +0000646{
Lei Zhang932cc2d2007-12-13 03:16:27 -0800647 ICOM_THIS_MULTI(VideoRendererImpl, IInner_vtbl, iface);
Christian Costaf096fa32004-08-24 02:28:35 +0000648 TRACE("(%p/%p)->(%s, %p)\n", This, iface, qzdebugstr_guid(riid), ppv);
649
Lei Zhang932cc2d2007-12-13 03:16:27 -0800650 if (This->bAggregatable)
651 This->bUnkOuterValid = TRUE;
652
Christian Costaf096fa32004-08-24 02:28:35 +0000653 *ppv = NULL;
654
655 if (IsEqualIID(riid, &IID_IUnknown))
Michael Stefaniuccc7fc4a2009-01-29 11:14:55 +0100656 *ppv = &This->IInner_vtbl;
Christian Costaf096fa32004-08-24 02:28:35 +0000657 else if (IsEqualIID(riid, &IID_IPersist))
Michael Stefaniuccc7fc4a2009-01-29 11:14:55 +0100658 *ppv = This;
Christian Costaf096fa32004-08-24 02:28:35 +0000659 else if (IsEqualIID(riid, &IID_IMediaFilter))
Michael Stefaniuccc7fc4a2009-01-29 11:14:55 +0100660 *ppv = This;
Christian Costaf096fa32004-08-24 02:28:35 +0000661 else if (IsEqualIID(riid, &IID_IBaseFilter))
Michael Stefaniuccc7fc4a2009-01-29 11:14:55 +0100662 *ppv = This;
Christian Costaf096fa32004-08-24 02:28:35 +0000663 else if (IsEqualIID(riid, &IID_IBasicVideo))
Michael Stefaniuccc7fc4a2009-01-29 11:14:55 +0100664 *ppv = &This->IBasicVideo_vtbl;
Christian Costaf096fa32004-08-24 02:28:35 +0000665 else if (IsEqualIID(riid, &IID_IVideoWindow))
Michael Stefaniuccc7fc4a2009-01-29 11:14:55 +0100666 *ppv = &This->IVideoWindow_vtbl;
Maarten Lankhorst2eb66372008-06-10 18:40:09 +0200667 else if (IsEqualIID(riid, &IID_IMediaSeeking))
668 *ppv = &This->mediaSeeking;
Christian Costaf096fa32004-08-24 02:28:35 +0000669
670 if (*ppv)
671 {
672 IUnknown_AddRef((IUnknown *)(*ppv));
673 return S_OK;
674 }
675
Maarten Lankhorstdb8b2ca2008-03-21 15:36:51 -0700676 if (!IsEqualIID(riid, &IID_IPin))
677 FIXME("No interface for %s!\n", qzdebugstr_guid(riid));
Christian Costaf096fa32004-08-24 02:28:35 +0000678
679 return E_NOINTERFACE;
680}
681
Lei Zhang63df94b2007-12-13 15:05:58 -0800682static ULONG WINAPI VideoRendererInner_AddRef(IUnknown * iface)
Christian Costaf096fa32004-08-24 02:28:35 +0000683{
Lei Zhang932cc2d2007-12-13 03:16:27 -0800684 ICOM_THIS_MULTI(VideoRendererImpl, IInner_vtbl, iface);
Paul Vriensc6559a12005-01-06 19:36:47 +0000685 ULONG refCount = InterlockedIncrement(&This->refCount);
Christian Costa9b8d5c62004-12-27 17:15:58 +0000686
Hans Leidekkercfbb8592006-10-12 20:57:23 +0200687 TRACE("(%p/%p)->() AddRef from %d\n", This, iface, refCount - 1);
Christian Costa9b8d5c62004-12-27 17:15:58 +0000688
Paul Vriensc6559a12005-01-06 19:36:47 +0000689 return refCount;
Christian Costaf096fa32004-08-24 02:28:35 +0000690}
691
Lei Zhang63df94b2007-12-13 15:05:58 -0800692static ULONG WINAPI VideoRendererInner_Release(IUnknown * iface)
Christian Costaf096fa32004-08-24 02:28:35 +0000693{
Lei Zhang932cc2d2007-12-13 03:16:27 -0800694 ICOM_THIS_MULTI(VideoRendererImpl, IInner_vtbl, iface);
Paul Vriensc6559a12005-01-06 19:36:47 +0000695 ULONG refCount = InterlockedDecrement(&This->refCount);
Christian Costa9b8d5c62004-12-27 17:15:58 +0000696
Hans Leidekkercfbb8592006-10-12 20:57:23 +0200697 TRACE("(%p/%p)->() Release from %d\n", This, iface, refCount + 1);
Christian Costa9b8d5c62004-12-27 17:15:58 +0000698
Paul Vriensc6559a12005-01-06 19:36:47 +0000699 if (!refCount)
Christian Costaf096fa32004-08-24 02:28:35 +0000700 {
Chris Robinson809f6842007-03-13 10:47:47 -0700701 IPin *pConnectedTo;
702
Christian Costaacb2ff22005-06-13 11:37:55 +0000703 DestroyWindow(This->hWnd);
704 PostThreadMessageA(This->ThreadID, WM_QUIT, 0, 0);
705 WaitForSingleObject(This->hThread, INFINITE);
706 CloseHandle(This->hThread);
Maarten Lankhorst9985f2e2008-07-04 01:33:04 -0700707 CloseHandle(This->hEvent);
Christian Costaacb2ff22005-06-13 11:37:55 +0000708
Christian Costacb6e4a12005-06-04 09:37:35 +0000709 if (This->pClock)
710 IReferenceClock_Release(This->pClock);
Christian Costaf096fa32004-08-24 02:28:35 +0000711
Maarten Lankhorst79349512008-04-25 14:25:49 -0700712 if (SUCCEEDED(IPin_ConnectedTo((IPin *)This->pInputPin, &pConnectedTo)))
Chris Robinson809f6842007-03-13 10:47:47 -0700713 {
714 IPin_Disconnect(pConnectedTo);
715 IPin_Release(pConnectedTo);
716 }
Maarten Lankhorst79349512008-04-25 14:25:49 -0700717 IPin_Disconnect((IPin *)This->pInputPin);
Chris Robinson809f6842007-03-13 10:47:47 -0700718
Maarten Lankhorst79349512008-04-25 14:25:49 -0700719 IPin_Release((IPin *)This->pInputPin);
720
Christian Costaf096fa32004-08-24 02:28:35 +0000721 This->lpVtbl = NULL;
722
Chris Robinson6bd3b152007-03-19 13:26:09 -0700723 This->csFilter.DebugInfo->Spare[0] = 0;
724 DeleteCriticalSection(&This->csFilter);
725
Christian Costaf096fa32004-08-24 02:28:35 +0000726 TRACE("Destroying Video Renderer\n");
727 CoTaskMemFree(This);
728
729 return 0;
730 }
731 else
Paul Vriensc6559a12005-01-06 19:36:47 +0000732 return refCount;
Christian Costaf096fa32004-08-24 02:28:35 +0000733}
734
Lei Zhang932cc2d2007-12-13 03:16:27 -0800735static const IUnknownVtbl IInner_VTable =
736{
Lei Zhang63df94b2007-12-13 15:05:58 -0800737 VideoRendererInner_QueryInterface,
738 VideoRendererInner_AddRef,
739 VideoRendererInner_Release
Lei Zhang932cc2d2007-12-13 03:16:27 -0800740};
741
742static HRESULT WINAPI VideoRenderer_QueryInterface(IBaseFilter * iface, REFIID riid, LPVOID * ppv)
743{
744 VideoRendererImpl *This = (VideoRendererImpl *)iface;
745
746 if (This->bAggregatable)
747 This->bUnkOuterValid = TRUE;
748
749 if (This->pUnkOuter)
750 {
751 if (This->bAggregatable)
752 return IUnknown_QueryInterface(This->pUnkOuter, riid, ppv);
753
754 if (IsEqualIID(riid, &IID_IUnknown))
755 {
756 HRESULT hr;
757
758 IUnknown_AddRef((IUnknown *)&(This->IInner_vtbl));
759 hr = IUnknown_QueryInterface((IUnknown *)&(This->IInner_vtbl), riid, ppv);
760 IUnknown_Release((IUnknown *)&(This->IInner_vtbl));
761 This->bAggregatable = TRUE;
762 return hr;
763 }
764
765 *ppv = NULL;
766 return E_NOINTERFACE;
767 }
768
769 return IUnknown_QueryInterface((IUnknown *)&(This->IInner_vtbl), riid, ppv);
770}
771
772static ULONG WINAPI VideoRenderer_AddRef(IBaseFilter * iface)
773{
774 VideoRendererImpl *This = (VideoRendererImpl *)iface;
775
776 if (This->pUnkOuter && This->bUnkOuterValid)
777 return IUnknown_AddRef(This->pUnkOuter);
778 return IUnknown_AddRef((IUnknown *)&(This->IInner_vtbl));
779}
780
781static ULONG WINAPI VideoRenderer_Release(IBaseFilter * iface)
782{
783 VideoRendererImpl *This = (VideoRendererImpl *)iface;
784
785 if (This->pUnkOuter && This->bUnkOuterValid)
786 return IUnknown_Release(This->pUnkOuter);
787 return IUnknown_Release((IUnknown *)&(This->IInner_vtbl));
788}
789
Christian Costaf096fa32004-08-24 02:28:35 +0000790/** IPersist methods **/
791
792static HRESULT WINAPI VideoRenderer_GetClassID(IBaseFilter * iface, CLSID * pClsid)
793{
Alexandre Julliardf5f7a182004-09-08 01:50:37 +0000794 VideoRendererImpl *This = (VideoRendererImpl *)iface;
Christian Costaf096fa32004-08-24 02:28:35 +0000795
796 TRACE("(%p/%p)->(%p)\n", This, iface, pClsid);
797
798 *pClsid = CLSID_VideoRenderer;
799
800 return S_OK;
801}
802
803/** IMediaFilter methods **/
804
805static HRESULT WINAPI VideoRenderer_Stop(IBaseFilter * iface)
806{
Alexandre Julliardf5f7a182004-09-08 01:50:37 +0000807 VideoRendererImpl *This = (VideoRendererImpl *)iface;
Christian Costaf096fa32004-08-24 02:28:35 +0000808
809 TRACE("(%p/%p)->()\n", This, iface);
810
811 EnterCriticalSection(&This->csFilter);
812 {
813 This->state = State_Stopped;
Maarten Lankhorst9985f2e2008-07-04 01:33:04 -0700814 SetEvent(This->hEvent);
815 SetEvent(This->blocked);
Christian Costaf096fa32004-08-24 02:28:35 +0000816 }
817 LeaveCriticalSection(&This->csFilter);
Maarten Lankhorstdae09d02008-06-10 18:45:25 +0200818
Christian Costaf096fa32004-08-24 02:28:35 +0000819 return S_OK;
820}
821
822static HRESULT WINAPI VideoRenderer_Pause(IBaseFilter * iface)
823{
Alexandre Julliardf5f7a182004-09-08 01:50:37 +0000824 VideoRendererImpl *This = (VideoRendererImpl *)iface;
Christian Costaf096fa32004-08-24 02:28:35 +0000825
826 TRACE("(%p/%p)->()\n", This, iface);
827
828 EnterCriticalSection(&This->csFilter);
Maarten Lankhorst9985f2e2008-07-04 01:33:04 -0700829 if (This->state != State_Paused)
Christian Costaf096fa32004-08-24 02:28:35 +0000830 {
Maarten Lankhorst01c6e642008-04-04 16:27:29 -0700831 if (This->state == State_Stopped)
Maarten Lankhorst9985f2e2008-07-04 01:33:04 -0700832 {
Maarten Lankhorst01c6e642008-04-04 16:27:29 -0700833 This->pInputPin->end_of_stream = 0;
Maarten Lankhorst9985f2e2008-07-04 01:33:04 -0700834 ResetEvent(This->hEvent);
835 }
Maarten Lankhorst01c6e642008-04-04 16:27:29 -0700836
Christian Costaf096fa32004-08-24 02:28:35 +0000837 This->state = State_Paused;
Maarten Lankhorst9985f2e2008-07-04 01:33:04 -0700838 ResetEvent(This->blocked);
Christian Costaf096fa32004-08-24 02:28:35 +0000839 }
840 LeaveCriticalSection(&This->csFilter);
841
842 return S_OK;
843}
844
845static HRESULT WINAPI VideoRenderer_Run(IBaseFilter * iface, REFERENCE_TIME tStart)
846{
Alexandre Julliardf5f7a182004-09-08 01:50:37 +0000847 VideoRendererImpl *This = (VideoRendererImpl *)iface;
Christian Costaf096fa32004-08-24 02:28:35 +0000848
849 TRACE("(%p/%p)->(%s)\n", This, iface, wine_dbgstr_longlong(tStart));
850
851 EnterCriticalSection(&This->csFilter);
Maarten Lankhorst79349512008-04-25 14:25:49 -0700852 if (This->state != State_Running)
Christian Costaf096fa32004-08-24 02:28:35 +0000853 {
Maarten Lankhorst01c6e642008-04-04 16:27:29 -0700854 if (This->state == State_Stopped)
Maarten Lankhorst9985f2e2008-07-04 01:33:04 -0700855 {
Maarten Lankhorst01c6e642008-04-04 16:27:29 -0700856 This->pInputPin->end_of_stream = 0;
Maarten Lankhorst9985f2e2008-07-04 01:33:04 -0700857 ResetEvent(This->hEvent);
858 }
859 SetEvent(This->blocked);
Maarten Lankhorst01c6e642008-04-04 16:27:29 -0700860
Christian Costaf096fa32004-08-24 02:28:35 +0000861 This->rtStreamStart = tStart;
862 This->state = State_Running;
863 }
864 LeaveCriticalSection(&This->csFilter);
865
866 return S_OK;
867}
868
869static HRESULT WINAPI VideoRenderer_GetState(IBaseFilter * iface, DWORD dwMilliSecsTimeout, FILTER_STATE *pState)
870{
Alexandre Julliardf5f7a182004-09-08 01:50:37 +0000871 VideoRendererImpl *This = (VideoRendererImpl *)iface;
Maarten Lankhorst9985f2e2008-07-04 01:33:04 -0700872 HRESULT hr;
Christian Costaf096fa32004-08-24 02:28:35 +0000873
Hans Leidekkercfbb8592006-10-12 20:57:23 +0200874 TRACE("(%p/%p)->(%d, %p)\n", This, iface, dwMilliSecsTimeout, pState);
Christian Costaf096fa32004-08-24 02:28:35 +0000875
Maarten Lankhorst9985f2e2008-07-04 01:33:04 -0700876 if (WaitForSingleObject(This->hEvent, dwMilliSecsTimeout) == WAIT_TIMEOUT)
877 hr = VFW_S_STATE_INTERMEDIATE;
878 else
879 hr = S_OK;
880
Christian Costaf096fa32004-08-24 02:28:35 +0000881 EnterCriticalSection(&This->csFilter);
882 {
883 *pState = This->state;
884 }
885 LeaveCriticalSection(&This->csFilter);
886
Maarten Lankhorst9985f2e2008-07-04 01:33:04 -0700887 return hr;
Christian Costaf096fa32004-08-24 02:28:35 +0000888}
889
890static HRESULT WINAPI VideoRenderer_SetSyncSource(IBaseFilter * iface, IReferenceClock *pClock)
891{
Alexandre Julliardf5f7a182004-09-08 01:50:37 +0000892 VideoRendererImpl *This = (VideoRendererImpl *)iface;
Christian Costaf096fa32004-08-24 02:28:35 +0000893
894 TRACE("(%p/%p)->(%p)\n", This, iface, pClock);
895
896 EnterCriticalSection(&This->csFilter);
897 {
898 if (This->pClock)
899 IReferenceClock_Release(This->pClock);
900 This->pClock = pClock;
901 if (This->pClock)
902 IReferenceClock_AddRef(This->pClock);
903 }
904 LeaveCriticalSection(&This->csFilter);
905
906 return S_OK;
907}
908
909static HRESULT WINAPI VideoRenderer_GetSyncSource(IBaseFilter * iface, IReferenceClock **ppClock)
910{
Alexandre Julliardf5f7a182004-09-08 01:50:37 +0000911 VideoRendererImpl *This = (VideoRendererImpl *)iface;
Christian Costaf096fa32004-08-24 02:28:35 +0000912
913 TRACE("(%p/%p)->(%p)\n", This, iface, ppClock);
914
915 EnterCriticalSection(&This->csFilter);
916 {
917 *ppClock = This->pClock;
Maarten Lankhorstf9c2d8e2008-04-19 15:19:32 -0700918 if (This->pClock)
919 IReferenceClock_AddRef(This->pClock);
Christian Costaf096fa32004-08-24 02:28:35 +0000920 }
921 LeaveCriticalSection(&This->csFilter);
922
923 return S_OK;
924}
925
926/** IBaseFilter implementation **/
927
Maarten Lankhorst79349512008-04-25 14:25:49 -0700928static HRESULT VideoRenderer_GetPin(IBaseFilter *iface, ULONG pos, IPin **pin, DWORD *lastsynctick)
929{
930 VideoRendererImpl *This = (VideoRendererImpl *)iface;
931
932 /* Our pins are static, not changing so setting static tick count is ok */
933 *lastsynctick = 0;
934
935 if (pos >= 1)
936 return S_FALSE;
937
938 *pin = (IPin *)This->pInputPin;
939 IPin_AddRef(*pin);
940 return S_OK;
941}
942
Christian Costaf096fa32004-08-24 02:28:35 +0000943static HRESULT WINAPI VideoRenderer_EnumPins(IBaseFilter * iface, IEnumPins **ppEnum)
944{
Alexandre Julliardf5f7a182004-09-08 01:50:37 +0000945 VideoRendererImpl *This = (VideoRendererImpl *)iface;
Christian Costaf096fa32004-08-24 02:28:35 +0000946
947 TRACE("(%p/%p)->(%p)\n", This, iface, ppEnum);
948
Maarten Lankhorst79349512008-04-25 14:25:49 -0700949 return IEnumPinsImpl_Construct(ppEnum, VideoRenderer_GetPin, iface);
Christian Costaf096fa32004-08-24 02:28:35 +0000950}
951
952static HRESULT WINAPI VideoRenderer_FindPin(IBaseFilter * iface, LPCWSTR Id, IPin **ppPin)
953{
Alexandre Julliardf5f7a182004-09-08 01:50:37 +0000954 VideoRendererImpl *This = (VideoRendererImpl *)iface;
Christian Costaf096fa32004-08-24 02:28:35 +0000955
Christian Costac83e4f12008-12-29 12:00:10 +0100956 FIXME("(%p/%p)->(%p,%p): stub !!!\n", This, iface, debugstr_w(Id), ppPin);
Christian Costaf096fa32004-08-24 02:28:35 +0000957
958 /* FIXME: critical section */
959
960 return E_NOTIMPL;
961}
962
963static HRESULT WINAPI VideoRenderer_QueryFilterInfo(IBaseFilter * iface, FILTER_INFO *pInfo)
964{
Alexandre Julliardf5f7a182004-09-08 01:50:37 +0000965 VideoRendererImpl *This = (VideoRendererImpl *)iface;
Christian Costaf096fa32004-08-24 02:28:35 +0000966
967 TRACE("(%p/%p)->(%p)\n", This, iface, pInfo);
968
969 strcpyW(pInfo->achName, This->filterInfo.achName);
970 pInfo->pGraph = This->filterInfo.pGraph;
971
972 if (pInfo->pGraph)
973 IFilterGraph_AddRef(pInfo->pGraph);
974
975 return S_OK;
976}
977
978static HRESULT WINAPI VideoRenderer_JoinFilterGraph(IBaseFilter * iface, IFilterGraph *pGraph, LPCWSTR pName)
979{
Alexandre Julliardf5f7a182004-09-08 01:50:37 +0000980 VideoRendererImpl *This = (VideoRendererImpl *)iface;
Christian Costaf096fa32004-08-24 02:28:35 +0000981
982 TRACE("(%p/%p)->(%p, %s)\n", This, iface, pGraph, debugstr_w(pName));
983
984 EnterCriticalSection(&This->csFilter);
985 {
986 if (pName)
987 strcpyW(This->filterInfo.achName, pName);
988 else
989 *This->filterInfo.achName = '\0';
990 This->filterInfo.pGraph = pGraph; /* NOTE: do NOT increase ref. count */
991 }
992 LeaveCriticalSection(&This->csFilter);
993
994 return S_OK;
995}
996
997static HRESULT WINAPI VideoRenderer_QueryVendorInfo(IBaseFilter * iface, LPWSTR *pVendorInfo)
998{
Alexandre Julliardf5f7a182004-09-08 01:50:37 +0000999 VideoRendererImpl *This = (VideoRendererImpl *)iface;
Christian Costaf096fa32004-08-24 02:28:35 +00001000 TRACE("(%p/%p)->(%p)\n", This, iface, pVendorInfo);
1001 return E_NOTIMPL;
1002}
1003
1004static const IBaseFilterVtbl VideoRenderer_Vtbl =
1005{
1006 VideoRenderer_QueryInterface,
1007 VideoRenderer_AddRef,
1008 VideoRenderer_Release,
1009 VideoRenderer_GetClassID,
1010 VideoRenderer_Stop,
1011 VideoRenderer_Pause,
1012 VideoRenderer_Run,
1013 VideoRenderer_GetState,
1014 VideoRenderer_SetSyncSource,
1015 VideoRenderer_GetSyncSource,
1016 VideoRenderer_EnumPins,
1017 VideoRenderer_FindPin,
1018 VideoRenderer_QueryFilterInfo,
1019 VideoRenderer_JoinFilterGraph,
1020 VideoRenderer_QueryVendorInfo
1021};
1022
Christian Costa7dea79c2005-03-02 10:12:12 +00001023static HRESULT WINAPI VideoRenderer_InputPin_EndOfStream(IPin * iface)
1024{
1025 InputPin* This = (InputPin*)iface;
1026 IMediaEventSink* pEventSink;
1027 HRESULT hr;
1028
1029 TRACE("(%p/%p)->()\n", This, iface);
1030
1031 hr = IFilterGraph_QueryInterface(((VideoRendererImpl*)This->pin.pinInfo.pFilter)->filterInfo.pGraph, &IID_IMediaEventSink, (LPVOID*)&pEventSink);
1032 if (SUCCEEDED(hr))
1033 {
1034 hr = IMediaEventSink_Notify(pEventSink, EC_COMPLETE, S_OK, 0);
1035 IMediaEventSink_Release(pEventSink);
1036 }
1037
1038 return hr;
1039}
1040
Maarten Lankhorst9985f2e2008-07-04 01:33:04 -07001041static HRESULT WINAPI VideoRenderer_InputPin_BeginFlush(IPin * iface)
1042{
1043 InputPin* This = (InputPin*)iface;
1044 VideoRendererImpl *pVideoRenderer = (VideoRendererImpl *)This->pin.pinInfo.pFilter;
1045 HRESULT hr;
1046
1047 TRACE("(%p/%p)->()\n", This, iface);
1048
1049 EnterCriticalSection(This->pin.pCritSec);
1050 if (pVideoRenderer->state == State_Paused)
1051 SetEvent(pVideoRenderer->blocked);
1052
1053 hr = InputPin_BeginFlush(iface);
1054 LeaveCriticalSection(This->pin.pCritSec);
1055
1056 return hr;
1057}
1058
1059static HRESULT WINAPI VideoRenderer_InputPin_EndFlush(IPin * iface)
1060{
1061 InputPin* This = (InputPin*)iface;
1062 VideoRendererImpl *pVideoRenderer = (VideoRendererImpl *)This->pin.pinInfo.pFilter;
1063 HRESULT hr;
1064
1065 TRACE("(%p/%p)->()\n", This, iface);
1066
1067 EnterCriticalSection(This->pin.pCritSec);
1068 if (pVideoRenderer->state == State_Paused)
1069 ResetEvent(pVideoRenderer->blocked);
1070
1071 hr = InputPin_EndFlush(iface);
1072 LeaveCriticalSection(This->pin.pCritSec);
1073
1074 return hr;
1075}
1076
Christian Costaf096fa32004-08-24 02:28:35 +00001077static const IPinVtbl VideoRenderer_InputPin_Vtbl =
1078{
1079 InputPin_QueryInterface,
1080 IPinImpl_AddRef,
1081 InputPin_Release,
1082 InputPin_Connect,
1083 InputPin_ReceiveConnection,
1084 IPinImpl_Disconnect,
1085 IPinImpl_ConnectedTo,
1086 IPinImpl_ConnectionMediaType,
1087 IPinImpl_QueryPinInfo,
1088 IPinImpl_QueryDirection,
1089 IPinImpl_QueryId,
1090 IPinImpl_QueryAccept,
1091 IPinImpl_EnumMediaTypes,
1092 IPinImpl_QueryInternalConnections,
Christian Costa7dea79c2005-03-02 10:12:12 +00001093 VideoRenderer_InputPin_EndOfStream,
Maarten Lankhorst9985f2e2008-07-04 01:33:04 -07001094 VideoRenderer_InputPin_BeginFlush,
1095 VideoRenderer_InputPin_EndFlush,
Christian Costaf096fa32004-08-24 02:28:35 +00001096 InputPin_NewSegment
1097};
1098
1099/*** IUnknown methods ***/
1100static HRESULT WINAPI Basicvideo_QueryInterface(IBasicVideo *iface,
1101 REFIID riid,
1102 LPVOID*ppvObj) {
1103 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1104
1105 TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_guid(riid), riid, ppvObj);
1106
1107 return VideoRenderer_QueryInterface((IBaseFilter*)This, riid, ppvObj);
1108}
1109
1110static ULONG WINAPI Basicvideo_AddRef(IBasicVideo *iface) {
1111 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1112
1113 TRACE("(%p/%p)->()\n", This, iface);
1114
1115 return VideoRenderer_AddRef((IBaseFilter*)This);
1116}
1117
1118static ULONG WINAPI Basicvideo_Release(IBasicVideo *iface) {
1119 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1120
1121 TRACE("(%p/%p)->()\n", This, iface);
1122
1123 return VideoRenderer_Release((IBaseFilter*)This);
1124}
1125
1126/*** IDispatch methods ***/
1127static HRESULT WINAPI Basicvideo_GetTypeInfoCount(IBasicVideo *iface,
1128 UINT*pctinfo) {
1129 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1130
Christian Costaacb2ff22005-06-13 11:37:55 +00001131 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, pctinfo);
Christian Costaf096fa32004-08-24 02:28:35 +00001132
1133 return S_OK;
1134}
1135
1136static HRESULT WINAPI Basicvideo_GetTypeInfo(IBasicVideo *iface,
1137 UINT iTInfo,
1138 LCID lcid,
1139 ITypeInfo**ppTInfo) {
1140 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1141
Hans Leidekkercfbb8592006-10-12 20:57:23 +02001142 FIXME("(%p/%p)->(%d, %d, %p): stub !!!\n", This, iface, iTInfo, lcid, ppTInfo);
Christian Costaf096fa32004-08-24 02:28:35 +00001143
1144 return S_OK;
1145}
1146
1147static HRESULT WINAPI Basicvideo_GetIDsOfNames(IBasicVideo *iface,
1148 REFIID riid,
1149 LPOLESTR*rgszNames,
1150 UINT cNames,
1151 LCID lcid,
1152 DISPID*rgDispId) {
1153 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1154
Hans Leidekkercfbb8592006-10-12 20:57:23 +02001155 FIXME("(%p/%p)->(%s (%p), %p, %d, %d, %p): stub !!!\n", This, iface, debugstr_guid(riid), riid, rgszNames, cNames, lcid, rgDispId);
Christian Costaf096fa32004-08-24 02:28:35 +00001156
1157 return S_OK;
1158}
1159
1160static HRESULT WINAPI Basicvideo_Invoke(IBasicVideo *iface,
1161 DISPID dispIdMember,
1162 REFIID riid,
1163 LCID lcid,
1164 WORD wFlags,
1165 DISPPARAMS*pDispParams,
1166 VARIANT*pVarResult,
1167 EXCEPINFO*pExepInfo,
1168 UINT*puArgErr) {
1169 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1170
Hans Leidekkercfbb8592006-10-12 20:57:23 +02001171 FIXME("(%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);
Christian Costaf096fa32004-08-24 02:28:35 +00001172
1173 return S_OK;
1174}
1175
1176/*** IBasicVideo methods ***/
1177static HRESULT WINAPI Basicvideo_get_AvgTimePerFrame(IBasicVideo *iface,
1178 REFTIME *pAvgTimePerFrame) {
Maarten Lankhorst44827a02010-05-17 21:32:32 +02001179 AM_MEDIA_TYPE *pmt;
Christian Costaf096fa32004-08-24 02:28:35 +00001180 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1181
Maarten Lankhorst44827a02010-05-17 21:32:32 +02001182 if (!This->pInputPin->pin.pConnectedTo)
1183 return VFW_E_NOT_CONNECTED;
Christian Costaf096fa32004-08-24 02:28:35 +00001184
Maarten Lankhorst44827a02010-05-17 21:32:32 +02001185 TRACE("(%p/%p)->(%p)\n", This, iface, pAvgTimePerFrame);
1186
1187 pmt = &This->pInputPin->pin.mtCurrent;
1188 if (IsEqualIID(&pmt->formattype, &FORMAT_VideoInfo)) {
1189 VIDEOINFOHEADER *vih = (VIDEOINFOHEADER*)pmt->pbFormat;
1190 *pAvgTimePerFrame = vih->AvgTimePerFrame;
1191 } else if (IsEqualIID(&pmt->formattype, &FORMAT_VideoInfo2)) {
1192 VIDEOINFOHEADER2 *vih = (VIDEOINFOHEADER2*)pmt->pbFormat;
1193 *pAvgTimePerFrame = vih->AvgTimePerFrame;
1194 } else {
1195 ERR("Unknown format type %s\n", qzdebugstr_guid(&pmt->formattype));
1196 *pAvgTimePerFrame = 0;
1197 }
Christian Costaf096fa32004-08-24 02:28:35 +00001198 return S_OK;
1199}
1200
1201static HRESULT WINAPI Basicvideo_get_BitRate(IBasicVideo *iface,
Michael Stefaniuca3269bd2009-03-11 00:31:26 +01001202 LONG *pBitRate) {
Christian Costaf096fa32004-08-24 02:28:35 +00001203 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1204
Christian Costaacb2ff22005-06-13 11:37:55 +00001205 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, pBitRate);
Christian Costaf096fa32004-08-24 02:28:35 +00001206
1207 return S_OK;
1208}
1209
1210static HRESULT WINAPI Basicvideo_get_BitErrorRate(IBasicVideo *iface,
Michael Stefaniuca3269bd2009-03-11 00:31:26 +01001211 LONG *pBitErrorRate) {
Christian Costaf096fa32004-08-24 02:28:35 +00001212 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1213
Christian Costaacb2ff22005-06-13 11:37:55 +00001214 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, pBitErrorRate);
Christian Costaf096fa32004-08-24 02:28:35 +00001215
1216 return S_OK;
1217}
1218
1219static HRESULT WINAPI Basicvideo_get_VideoWidth(IBasicVideo *iface,
Michael Stefaniuca3269bd2009-03-11 00:31:26 +01001220 LONG *pVideoWidth) {
Christian Costaf096fa32004-08-24 02:28:35 +00001221 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1222
Christian Costaacb2ff22005-06-13 11:37:55 +00001223 TRACE("(%p/%p)->(%p)\n", This, iface, pVideoWidth);
1224
1225 *pVideoWidth = This->VideoWidth;
Christian Costaf096fa32004-08-24 02:28:35 +00001226
1227 return S_OK;
1228}
1229
1230static HRESULT WINAPI Basicvideo_get_VideoHeight(IBasicVideo *iface,
Michael Stefaniuca3269bd2009-03-11 00:31:26 +01001231 LONG *pVideoHeight) {
Christian Costaf096fa32004-08-24 02:28:35 +00001232 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1233
Christian Costaacb2ff22005-06-13 11:37:55 +00001234 TRACE("(%p/%p)->(%p)\n", This, iface, pVideoHeight);
1235
1236 *pVideoHeight = This->VideoHeight;
Christian Costaf096fa32004-08-24 02:28:35 +00001237
1238 return S_OK;
1239}
1240
1241static HRESULT WINAPI Basicvideo_put_SourceLeft(IBasicVideo *iface,
Michael Stefaniuca3269bd2009-03-11 00:31:26 +01001242 LONG SourceLeft) {
Christian Costaf096fa32004-08-24 02:28:35 +00001243 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1244
Michael Stefaniuca3269bd2009-03-11 00:31:26 +01001245 TRACE("(%p/%p)->(%d)\n", This, iface, SourceLeft);
Christian Costaacb2ff22005-06-13 11:37:55 +00001246
1247 This->SourceRect.left = SourceLeft;
Christian Costaf096fa32004-08-24 02:28:35 +00001248
1249 return S_OK;
1250}
1251
1252static HRESULT WINAPI Basicvideo_get_SourceLeft(IBasicVideo *iface,
Michael Stefaniuca3269bd2009-03-11 00:31:26 +01001253 LONG *pSourceLeft) {
Christian Costaf096fa32004-08-24 02:28:35 +00001254 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1255
Christian Costaacb2ff22005-06-13 11:37:55 +00001256 TRACE("(%p/%p)->(%p)\n", This, iface, pSourceLeft);
1257
1258 *pSourceLeft = This->SourceRect.left;
Christian Costaf096fa32004-08-24 02:28:35 +00001259
1260 return S_OK;
1261}
1262
1263static HRESULT WINAPI Basicvideo_put_SourceWidth(IBasicVideo *iface,
Michael Stefaniuca3269bd2009-03-11 00:31:26 +01001264 LONG SourceWidth) {
Christian Costaf096fa32004-08-24 02:28:35 +00001265 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1266
Michael Stefaniuca3269bd2009-03-11 00:31:26 +01001267 TRACE("(%p/%p)->(%d)\n", This, iface, SourceWidth);
Christian Costaacb2ff22005-06-13 11:37:55 +00001268
1269 This->SourceRect.right = This->SourceRect.left + SourceWidth;
Christian Costaf096fa32004-08-24 02:28:35 +00001270
1271 return S_OK;
1272}
1273
1274static HRESULT WINAPI Basicvideo_get_SourceWidth(IBasicVideo *iface,
Michael Stefaniuca3269bd2009-03-11 00:31:26 +01001275 LONG *pSourceWidth) {
Christian Costaf096fa32004-08-24 02:28:35 +00001276 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1277
Christian Costaacb2ff22005-06-13 11:37:55 +00001278 TRACE("(%p/%p)->(%p)\n", This, iface, pSourceWidth);
Christian Costaf096fa32004-08-24 02:28:35 +00001279
Christian Costaacb2ff22005-06-13 11:37:55 +00001280 *pSourceWidth = This->SourceRect.right - This->SourceRect.left;
1281
Christian Costaf096fa32004-08-24 02:28:35 +00001282 return S_OK;
1283}
1284
1285static HRESULT WINAPI Basicvideo_put_SourceTop(IBasicVideo *iface,
Michael Stefaniuca3269bd2009-03-11 00:31:26 +01001286 LONG SourceTop) {
Christian Costaf096fa32004-08-24 02:28:35 +00001287 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1288
Michael Stefaniuca3269bd2009-03-11 00:31:26 +01001289 TRACE("(%p/%p)->(%d)\n", This, iface, SourceTop);
Christian Costaacb2ff22005-06-13 11:37:55 +00001290
1291 This->SourceRect.top = SourceTop;
Christian Costaf096fa32004-08-24 02:28:35 +00001292
1293 return S_OK;
1294}
1295
1296static HRESULT WINAPI Basicvideo_get_SourceTop(IBasicVideo *iface,
Michael Stefaniuca3269bd2009-03-11 00:31:26 +01001297 LONG *pSourceTop) {
Christian Costaf096fa32004-08-24 02:28:35 +00001298 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1299
Christian Costaacb2ff22005-06-13 11:37:55 +00001300 TRACE("(%p/%p)->(%p)\n", This, iface, pSourceTop);
1301
1302 *pSourceTop = This->SourceRect.top;
Christian Costaf096fa32004-08-24 02:28:35 +00001303
1304 return S_OK;
1305}
1306
1307static HRESULT WINAPI Basicvideo_put_SourceHeight(IBasicVideo *iface,
Michael Stefaniuca3269bd2009-03-11 00:31:26 +01001308 LONG SourceHeight) {
Christian Costaf096fa32004-08-24 02:28:35 +00001309 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1310
Michael Stefaniuca3269bd2009-03-11 00:31:26 +01001311 TRACE("(%p/%p)->(%d)\n", This, iface, SourceHeight);
Christian Costaacb2ff22005-06-13 11:37:55 +00001312
1313 This->SourceRect.bottom = This->SourceRect.top + SourceHeight;
Christian Costaf096fa32004-08-24 02:28:35 +00001314
1315 return S_OK;
1316}
1317
1318static HRESULT WINAPI Basicvideo_get_SourceHeight(IBasicVideo *iface,
Michael Stefaniuca3269bd2009-03-11 00:31:26 +01001319 LONG *pSourceHeight) {
Christian Costaf096fa32004-08-24 02:28:35 +00001320 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1321
Christian Costaacb2ff22005-06-13 11:37:55 +00001322 TRACE("(%p/%p)->(%p)\n", This, iface, pSourceHeight);
1323
1324 *pSourceHeight = This->SourceRect.bottom - This->SourceRect.top;
Christian Costaf096fa32004-08-24 02:28:35 +00001325
1326 return S_OK;
1327}
1328
1329static HRESULT WINAPI Basicvideo_put_DestinationLeft(IBasicVideo *iface,
Michael Stefaniuca3269bd2009-03-11 00:31:26 +01001330 LONG DestinationLeft) {
Christian Costaf096fa32004-08-24 02:28:35 +00001331 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1332
Michael Stefaniuca3269bd2009-03-11 00:31:26 +01001333 TRACE("(%p/%p)->(%d)\n", This, iface, DestinationLeft);
Christian Costaacb2ff22005-06-13 11:37:55 +00001334
1335 This->DestRect.left = DestinationLeft;
Christian Costaf096fa32004-08-24 02:28:35 +00001336
1337 return S_OK;
1338}
1339
1340static HRESULT WINAPI Basicvideo_get_DestinationLeft(IBasicVideo *iface,
Michael Stefaniuca3269bd2009-03-11 00:31:26 +01001341 LONG *pDestinationLeft) {
Christian Costaf096fa32004-08-24 02:28:35 +00001342 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1343
Christian Costaacb2ff22005-06-13 11:37:55 +00001344 TRACE("(%p/%p)->(%p)\n", This, iface, pDestinationLeft);
1345
1346 *pDestinationLeft = This->DestRect.left;
Christian Costaf096fa32004-08-24 02:28:35 +00001347
1348 return S_OK;
1349}
1350
1351static HRESULT WINAPI Basicvideo_put_DestinationWidth(IBasicVideo *iface,
Michael Stefaniuca3269bd2009-03-11 00:31:26 +01001352 LONG DestinationWidth) {
Christian Costaf096fa32004-08-24 02:28:35 +00001353 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1354
Michael Stefaniuca3269bd2009-03-11 00:31:26 +01001355 TRACE("(%p/%p)->(%d)\n", This, iface, DestinationWidth);
Christian Costaacb2ff22005-06-13 11:37:55 +00001356
1357 This->DestRect.right = This->DestRect.left + DestinationWidth;
Christian Costaf096fa32004-08-24 02:28:35 +00001358
1359 return S_OK;
1360}
1361
1362static HRESULT WINAPI Basicvideo_get_DestinationWidth(IBasicVideo *iface,
Michael Stefaniuca3269bd2009-03-11 00:31:26 +01001363 LONG *pDestinationWidth) {
Christian Costaf096fa32004-08-24 02:28:35 +00001364 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1365
Christian Costaacb2ff22005-06-13 11:37:55 +00001366 TRACE("(%p/%p)->(%p)\n", This, iface, pDestinationWidth);
1367
1368 *pDestinationWidth = This->DestRect.right - This->DestRect.left;
Christian Costaf096fa32004-08-24 02:28:35 +00001369
1370 return S_OK;
1371}
1372
1373static HRESULT WINAPI Basicvideo_put_DestinationTop(IBasicVideo *iface,
Michael Stefaniuca3269bd2009-03-11 00:31:26 +01001374 LONG DestinationTop) {
Christian Costaf096fa32004-08-24 02:28:35 +00001375 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1376
Michael Stefaniuca3269bd2009-03-11 00:31:26 +01001377 TRACE("(%p/%p)->(%d)\n", This, iface, DestinationTop);
Christian Costaf096fa32004-08-24 02:28:35 +00001378
Christian Costaacb2ff22005-06-13 11:37:55 +00001379 This->DestRect.top = DestinationTop;
1380
Christian Costaf096fa32004-08-24 02:28:35 +00001381 return S_OK;
1382}
1383
1384static HRESULT WINAPI Basicvideo_get_DestinationTop(IBasicVideo *iface,
Michael Stefaniuca3269bd2009-03-11 00:31:26 +01001385 LONG *pDestinationTop) {
Christian Costaf096fa32004-08-24 02:28:35 +00001386 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1387
Christian Costaacb2ff22005-06-13 11:37:55 +00001388 TRACE("(%p/%p)->(%p)\n", This, iface, pDestinationTop);
1389
1390 *pDestinationTop = This->DestRect.top;
Christian Costaf096fa32004-08-24 02:28:35 +00001391
1392 return S_OK;
1393}
1394
1395static HRESULT WINAPI Basicvideo_put_DestinationHeight(IBasicVideo *iface,
Michael Stefaniuca3269bd2009-03-11 00:31:26 +01001396 LONG DestinationHeight) {
Christian Costaf096fa32004-08-24 02:28:35 +00001397 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1398
Michael Stefaniuca3269bd2009-03-11 00:31:26 +01001399 TRACE("(%p/%p)->(%d)\n", This, iface, DestinationHeight);
Christian Costaacb2ff22005-06-13 11:37:55 +00001400
1401 This->DestRect.right = This->DestRect.left + DestinationHeight;
Christian Costaf096fa32004-08-24 02:28:35 +00001402
1403 return S_OK;
1404}
1405
1406static HRESULT WINAPI Basicvideo_get_DestinationHeight(IBasicVideo *iface,
Michael Stefaniuca3269bd2009-03-11 00:31:26 +01001407 LONG *pDestinationHeight) {
Christian Costaf096fa32004-08-24 02:28:35 +00001408 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1409
Christian Costaacb2ff22005-06-13 11:37:55 +00001410 TRACE("(%p/%p)->(%p)\n", This, iface, pDestinationHeight);
1411
1412 *pDestinationHeight = This->DestRect.right - This->DestRect.left;
Christian Costaf096fa32004-08-24 02:28:35 +00001413
1414 return S_OK;
1415}
1416
1417static HRESULT WINAPI Basicvideo_SetSourcePosition(IBasicVideo *iface,
Michael Stefaniuca3269bd2009-03-11 00:31:26 +01001418 LONG Left,
1419 LONG Top,
1420 LONG Width,
1421 LONG Height) {
Christian Costaf096fa32004-08-24 02:28:35 +00001422 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1423
Michael Stefaniuca3269bd2009-03-11 00:31:26 +01001424 TRACE("(%p/%p)->(%d, %d, %d, %d)\n", This, iface, Left, Top, Width, Height);
Christian Costaf096fa32004-08-24 02:28:35 +00001425
Christian Costaacb2ff22005-06-13 11:37:55 +00001426 This->SourceRect.left = Left;
1427 This->SourceRect.top = Top;
1428 This->SourceRect.right = Left + Width;
1429 This->SourceRect.bottom = Top + Height;
1430
Christian Costaf096fa32004-08-24 02:28:35 +00001431 return S_OK;
1432}
1433
1434static HRESULT WINAPI Basicvideo_GetSourcePosition(IBasicVideo *iface,
Michael Stefaniuca3269bd2009-03-11 00:31:26 +01001435 LONG *pLeft,
1436 LONG *pTop,
1437 LONG *pWidth,
1438 LONG *pHeight) {
Christian Costaf096fa32004-08-24 02:28:35 +00001439 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1440
Christian Costaacb2ff22005-06-13 11:37:55 +00001441 TRACE("(%p/%p)->(%p, %p, %p, %p)\n", This, iface, pLeft, pTop, pWidth, pHeight);
Christian Costaf096fa32004-08-24 02:28:35 +00001442
Christian Costaacb2ff22005-06-13 11:37:55 +00001443 *pLeft = This->SourceRect.left;
1444 *pTop = This->SourceRect.top;
1445 *pWidth = This->SourceRect.right - This->SourceRect.left;
1446 *pHeight = This->SourceRect.bottom - This->SourceRect.top;
1447
Christian Costaf096fa32004-08-24 02:28:35 +00001448 return S_OK;
1449}
1450
1451static HRESULT WINAPI Basicvideo_SetDefaultSourcePosition(IBasicVideo *iface) {
1452 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1453
Christian Costaacb2ff22005-06-13 11:37:55 +00001454 TRACE("(%p/%p)->()\n", This, iface);
1455
1456 This->SourceRect.left = 0;
1457 This->SourceRect.top = 0;
1458 This->SourceRect.right = This->VideoWidth;
1459 This->SourceRect.bottom = This->VideoHeight;
Christian Costaf096fa32004-08-24 02:28:35 +00001460
1461 return S_OK;
1462}
1463
1464static HRESULT WINAPI Basicvideo_SetDestinationPosition(IBasicVideo *iface,
Michael Stefaniuca3269bd2009-03-11 00:31:26 +01001465 LONG Left,
1466 LONG Top,
1467 LONG Width,
1468 LONG Height) {
Christian Costaf096fa32004-08-24 02:28:35 +00001469 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1470
Michael Stefaniuca3269bd2009-03-11 00:31:26 +01001471 TRACE("(%p/%p)->(%d, %d, %d, %d)\n", This, iface, Left, Top, Width, Height);
Christian Costaacb2ff22005-06-13 11:37:55 +00001472
1473 This->DestRect.left = Left;
1474 This->DestRect.top = Top;
1475 This->DestRect.right = Left + Width;
1476 This->DestRect.bottom = Top + Height;
Christian Costaf096fa32004-08-24 02:28:35 +00001477
1478 return S_OK;
1479}
1480
1481static HRESULT WINAPI Basicvideo_GetDestinationPosition(IBasicVideo *iface,
Michael Stefaniuca3269bd2009-03-11 00:31:26 +01001482 LONG *pLeft,
1483 LONG *pTop,
1484 LONG *pWidth,
1485 LONG *pHeight) {
Christian Costaf096fa32004-08-24 02:28:35 +00001486 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1487
Christian Costaacb2ff22005-06-13 11:37:55 +00001488 TRACE("(%p/%p)->(%p, %p, %p, %p)\n", This, iface, pLeft, pTop, pWidth, pHeight);
1489
1490 *pLeft = This->DestRect.left;
1491 *pTop = This->DestRect.top;
1492 *pWidth = This->DestRect.right - This->DestRect.left;
1493 *pHeight = This->DestRect.bottom - This->DestRect.top;
Christian Costaf096fa32004-08-24 02:28:35 +00001494
1495 return S_OK;
1496}
1497
1498static HRESULT WINAPI Basicvideo_SetDefaultDestinationPosition(IBasicVideo *iface) {
1499 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
Christian Costaacb2ff22005-06-13 11:37:55 +00001500 RECT rect;
Christian Costaf096fa32004-08-24 02:28:35 +00001501
Christian Costaacb2ff22005-06-13 11:37:55 +00001502 TRACE("(%p/%p)->()\n", This, iface);
Christian Costaf096fa32004-08-24 02:28:35 +00001503
Christian Costaacb2ff22005-06-13 11:37:55 +00001504 if (!GetClientRect(This->hWnd, &rect))
1505 return E_FAIL;
1506
1507 This->SourceRect.left = 0;
1508 This->SourceRect.top = 0;
1509 This->SourceRect.right = rect.right;
1510 This->SourceRect.bottom = rect.bottom;
1511
Christian Costaf096fa32004-08-24 02:28:35 +00001512 return S_OK;
1513}
1514
1515static HRESULT WINAPI Basicvideo_GetVideoSize(IBasicVideo *iface,
Michael Stefaniuca3269bd2009-03-11 00:31:26 +01001516 LONG *pWidth,
1517 LONG *pHeight) {
Christian Costaf096fa32004-08-24 02:28:35 +00001518 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1519
Christian Costaacb2ff22005-06-13 11:37:55 +00001520 TRACE("(%p/%p)->(%p, %p)\n", This, iface, pWidth, pHeight);
Christian Costaf096fa32004-08-24 02:28:35 +00001521
Christian Costaacb2ff22005-06-13 11:37:55 +00001522 *pWidth = This->VideoWidth;
1523 *pHeight = This->VideoHeight;
1524
Christian Costaf096fa32004-08-24 02:28:35 +00001525 return S_OK;
1526}
1527
1528static HRESULT WINAPI Basicvideo_GetVideoPaletteEntries(IBasicVideo *iface,
Michael Stefaniuca3269bd2009-03-11 00:31:26 +01001529 LONG StartIndex,
1530 LONG Entries,
1531 LONG *pRetrieved,
1532 LONG *pPalette) {
Christian Costaf096fa32004-08-24 02:28:35 +00001533 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1534
Michael Stefaniuca3269bd2009-03-11 00:31:26 +01001535 FIXME("(%p/%p)->(%d, %d, %p, %p): stub !!!\n", This, iface, StartIndex, Entries, pRetrieved, pPalette);
Christian Costaf096fa32004-08-24 02:28:35 +00001536
1537 return S_OK;
1538}
1539
1540static HRESULT WINAPI Basicvideo_GetCurrentImage(IBasicVideo *iface,
Michael Stefaniuca3269bd2009-03-11 00:31:26 +01001541 LONG *pBufferSize,
1542 LONG *pDIBImage) {
Christian Costaf096fa32004-08-24 02:28:35 +00001543 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
Maarten Lankhorstdae09d02008-06-10 18:45:25 +02001544 BITMAPINFOHEADER *bmiHeader;
1545 LONG needed_size;
1546 AM_MEDIA_TYPE *amt = &This->pInputPin->pin.mtCurrent;
1547 char *ptr;
Christian Costaf096fa32004-08-24 02:28:35 +00001548
Christian Costac83e4f12008-12-29 12:00:10 +01001549 FIXME("(%p/%p)->(%p, %p): partial stub\n", This, iface, pBufferSize, pDIBImage);
1550
Maarten Lankhorstdae09d02008-06-10 18:45:25 +02001551 EnterCriticalSection(&This->csFilter);
1552
1553 if (!This->sample_held)
1554 {
1555 LeaveCriticalSection(&This->csFilter);
1556 return (This->state == State_Paused ? E_UNEXPECTED : VFW_E_NOT_PAUSED);
1557 }
1558
Maarten Lankhorstdae09d02008-06-10 18:45:25 +02001559 if (IsEqualIID(&amt->formattype, &FORMAT_VideoInfo))
1560 {
1561 bmiHeader = &((VIDEOINFOHEADER *)amt->pbFormat)->bmiHeader;
1562 }
1563 else if (IsEqualIID(&amt->formattype, &FORMAT_VideoInfo2))
1564 {
1565 bmiHeader = &((VIDEOINFOHEADER2 *)amt->pbFormat)->bmiHeader;
1566 }
1567 else
1568 {
1569 FIXME("Unknown type %s\n", debugstr_guid(&amt->subtype));
1570 LeaveCriticalSection(&This->csFilter);
1571 return VFW_E_RUNTIME_ERROR;
1572 }
1573
1574 needed_size = bmiHeader->biSize;
1575 needed_size += IMediaSample_GetActualDataLength(This->sample_held);
1576
1577 if (!pDIBImage)
1578 {
1579 *pBufferSize = needed_size;
1580 LeaveCriticalSection(&This->csFilter);
1581 return S_OK;
1582 }
1583
1584 if (needed_size < *pBufferSize)
1585 {
Michael Stefaniuca3269bd2009-03-11 00:31:26 +01001586 ERR("Buffer too small %u/%u\n", needed_size, *pBufferSize);
Maarten Lankhorstdae09d02008-06-10 18:45:25 +02001587 LeaveCriticalSection(&This->csFilter);
1588 return E_FAIL;
1589 }
1590 *pBufferSize = needed_size;
1591
1592 memcpy(pDIBImage, bmiHeader, bmiHeader->biSize);
1593 IMediaSample_GetPointer(This->sample_held, (BYTE **)&ptr);
1594 memcpy((char *)pDIBImage + bmiHeader->biSize, ptr, IMediaSample_GetActualDataLength(This->sample_held));
1595
1596 LeaveCriticalSection(&This->csFilter);
Christian Costaf096fa32004-08-24 02:28:35 +00001597
1598 return S_OK;
1599}
1600
1601static HRESULT WINAPI Basicvideo_IsUsingDefaultSource(IBasicVideo *iface) {
1602 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1603
Christian Costaacb2ff22005-06-13 11:37:55 +00001604 FIXME("(%p/%p)->(): stub !!!\n", This, iface);
Christian Costaf096fa32004-08-24 02:28:35 +00001605
1606 return S_OK;
1607}
1608
1609static HRESULT WINAPI Basicvideo_IsUsingDefaultDestination(IBasicVideo *iface) {
1610 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1611
Christian Costaacb2ff22005-06-13 11:37:55 +00001612 FIXME("(%p/%p)->(): stub !!!\n", This, iface);
Christian Costaf096fa32004-08-24 02:28:35 +00001613
1614 return S_OK;
1615}
1616
1617
Dmitry Timoshkoveba47f12005-06-06 19:50:35 +00001618static const IBasicVideoVtbl IBasicVideo_VTable =
Christian Costaf096fa32004-08-24 02:28:35 +00001619{
1620 Basicvideo_QueryInterface,
1621 Basicvideo_AddRef,
1622 Basicvideo_Release,
1623 Basicvideo_GetTypeInfoCount,
1624 Basicvideo_GetTypeInfo,
1625 Basicvideo_GetIDsOfNames,
1626 Basicvideo_Invoke,
1627 Basicvideo_get_AvgTimePerFrame,
1628 Basicvideo_get_BitRate,
1629 Basicvideo_get_BitErrorRate,
1630 Basicvideo_get_VideoWidth,
1631 Basicvideo_get_VideoHeight,
1632 Basicvideo_put_SourceLeft,
1633 Basicvideo_get_SourceLeft,
1634 Basicvideo_put_SourceWidth,
1635 Basicvideo_get_SourceWidth,
1636 Basicvideo_put_SourceTop,
1637 Basicvideo_get_SourceTop,
1638 Basicvideo_put_SourceHeight,
1639 Basicvideo_get_SourceHeight,
1640 Basicvideo_put_DestinationLeft,
1641 Basicvideo_get_DestinationLeft,
1642 Basicvideo_put_DestinationWidth,
1643 Basicvideo_get_DestinationWidth,
1644 Basicvideo_put_DestinationTop,
1645 Basicvideo_get_DestinationTop,
1646 Basicvideo_put_DestinationHeight,
1647 Basicvideo_get_DestinationHeight,
1648 Basicvideo_SetSourcePosition,
1649 Basicvideo_GetSourcePosition,
1650 Basicvideo_SetDefaultSourcePosition,
1651 Basicvideo_SetDestinationPosition,
1652 Basicvideo_GetDestinationPosition,
1653 Basicvideo_SetDefaultDestinationPosition,
1654 Basicvideo_GetVideoSize,
1655 Basicvideo_GetVideoPaletteEntries,
1656 Basicvideo_GetCurrentImage,
1657 Basicvideo_IsUsingDefaultSource,
1658 Basicvideo_IsUsingDefaultDestination
1659};
1660
1661
1662/*** IUnknown methods ***/
1663static HRESULT WINAPI Videowindow_QueryInterface(IVideoWindow *iface,
1664 REFIID riid,
1665 LPVOID*ppvObj) {
1666 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1667
1668 TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_guid(riid), riid, ppvObj);
1669
1670 return VideoRenderer_QueryInterface((IBaseFilter*)This, riid, ppvObj);
1671}
1672
1673static ULONG WINAPI Videowindow_AddRef(IVideoWindow *iface) {
1674 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1675
1676 TRACE("(%p/%p)->()\n", This, iface);
1677
1678 return VideoRenderer_AddRef((IBaseFilter*)This);
1679}
1680
1681static ULONG WINAPI Videowindow_Release(IVideoWindow *iface) {
1682 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1683
1684 TRACE("(%p/%p)->()\n", This, iface);
1685
1686 return VideoRenderer_Release((IBaseFilter*)This);
1687}
1688
1689/*** IDispatch methods ***/
1690static HRESULT WINAPI Videowindow_GetTypeInfoCount(IVideoWindow *iface,
1691 UINT*pctinfo) {
1692 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1693
Christian Costaacb2ff22005-06-13 11:37:55 +00001694 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, pctinfo);
Christian Costaf096fa32004-08-24 02:28:35 +00001695
1696 return S_OK;
1697}
1698
1699static HRESULT WINAPI Videowindow_GetTypeInfo(IVideoWindow *iface,
1700 UINT iTInfo,
1701 LCID lcid,
1702 ITypeInfo**ppTInfo) {
1703 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1704
Hans Leidekkercfbb8592006-10-12 20:57:23 +02001705 FIXME("(%p/%p)->(%d, %d, %p): stub !!!\n", This, iface, iTInfo, lcid, ppTInfo);
Christian Costaf096fa32004-08-24 02:28:35 +00001706
1707 return S_OK;
1708}
1709
1710static HRESULT WINAPI Videowindow_GetIDsOfNames(IVideoWindow *iface,
1711 REFIID riid,
1712 LPOLESTR*rgszNames,
1713 UINT cNames,
1714 LCID lcid,
1715 DISPID*rgDispId) {
1716 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1717
Hans Leidekkercfbb8592006-10-12 20:57:23 +02001718 FIXME("(%p/%p)->(%s (%p), %p, %d, %d, %p): stub !!!\n", This, iface, debugstr_guid(riid), riid, rgszNames, cNames, lcid, rgDispId);
Christian Costaf096fa32004-08-24 02:28:35 +00001719
1720 return S_OK;
1721}
1722
1723static HRESULT WINAPI Videowindow_Invoke(IVideoWindow *iface,
1724 DISPID dispIdMember,
1725 REFIID riid,
1726 LCID lcid,
1727 WORD wFlags,
1728 DISPPARAMS*pDispParams,
1729 VARIANT*pVarResult,
1730 EXCEPINFO*pExepInfo,
1731 UINT*puArgErr) {
1732 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1733
Hans Leidekkercfbb8592006-10-12 20:57:23 +02001734 FIXME("(%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);
Christian Costaf096fa32004-08-24 02:28:35 +00001735
1736 return S_OK;
1737}
1738
1739/*** IVideoWindow methods ***/
1740static HRESULT WINAPI Videowindow_put_Caption(IVideoWindow *iface,
1741 BSTR strCaption) {
1742 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1743
Christian Costaacb2ff22005-06-13 11:37:55 +00001744 TRACE("(%p/%p)->(%s (%p))\n", This, iface, debugstr_w(strCaption), strCaption);
1745
1746 if (!SetWindowTextW(This->hWnd, strCaption))
1747 return E_FAIL;
Christian Costaf096fa32004-08-24 02:28:35 +00001748
1749 return S_OK;
1750}
1751
1752static HRESULT WINAPI Videowindow_get_Caption(IVideoWindow *iface,
1753 BSTR *strCaption) {
1754 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1755
Christian Costaacb2ff22005-06-13 11:37:55 +00001756 TRACE("(%p/%p)->(%p)\n", This, iface, strCaption);
1757
1758 GetWindowTextW(This->hWnd, (LPWSTR)strCaption, 100);
Christian Costaf096fa32004-08-24 02:28:35 +00001759
1760 return S_OK;
1761}
1762
1763static HRESULT WINAPI Videowindow_put_WindowStyle(IVideoWindow *iface,
Michael Stefaniuca3269bd2009-03-11 00:31:26 +01001764 LONG WindowStyle) {
Christian Costaf096fa32004-08-24 02:28:35 +00001765 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
Christian Costaacb2ff22005-06-13 11:37:55 +00001766 LONG old;
Christian Costaf096fa32004-08-24 02:28:35 +00001767
Christian Costaacb2ff22005-06-13 11:37:55 +00001768 old = GetWindowLongA(This->hWnd, GWL_STYLE);
Michael Stefaniuca3269bd2009-03-11 00:31:26 +01001769
1770 TRACE("(%p/%p)->(%x -> %x)\n", This, iface, old, WindowStyle);
Christian Costaacb2ff22005-06-13 11:37:55 +00001771
1772 if (WindowStyle & (WS_DISABLED|WS_HSCROLL|WS_ICONIC|WS_MAXIMIZE|WS_MINIMIZE|WS_VSCROLL))
1773 return E_INVALIDARG;
1774
1775 SetWindowLongA(This->hWnd, GWL_STYLE, WindowStyle);
Christian Costaf096fa32004-08-24 02:28:35 +00001776
1777 return S_OK;
1778}
1779
1780static HRESULT WINAPI Videowindow_get_WindowStyle(IVideoWindow *iface,
Michael Stefaniuca3269bd2009-03-11 00:31:26 +01001781 LONG *WindowStyle) {
Christian Costaf096fa32004-08-24 02:28:35 +00001782 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1783
Christian Costaacb2ff22005-06-13 11:37:55 +00001784 TRACE("(%p/%p)->(%p)\n", This, iface, WindowStyle);
1785
1786 *WindowStyle = GetWindowLongA(This->hWnd, GWL_STYLE);
Christian Costaf096fa32004-08-24 02:28:35 +00001787
1788 return S_OK;
1789}
1790
1791static HRESULT WINAPI Videowindow_put_WindowStyleEx(IVideoWindow *iface,
Michael Stefaniuca3269bd2009-03-11 00:31:26 +01001792 LONG WindowStyleEx) {
Christian Costaf096fa32004-08-24 02:28:35 +00001793 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1794
Michael Stefaniuca3269bd2009-03-11 00:31:26 +01001795 TRACE("(%p/%p)->(%d)\n", This, iface, WindowStyleEx);
Christian Costaacb2ff22005-06-13 11:37:55 +00001796
1797 if (WindowStyleEx & (WS_DISABLED|WS_HSCROLL|WS_ICONIC|WS_MAXIMIZE|WS_MINIMIZE|WS_VSCROLL))
1798 return E_INVALIDARG;
1799
1800 if (!SetWindowLongA(This->hWnd, GWL_EXSTYLE, WindowStyleEx))
1801 return E_FAIL;
Christian Costaf096fa32004-08-24 02:28:35 +00001802
1803 return S_OK;
1804}
1805
1806static HRESULT WINAPI Videowindow_get_WindowStyleEx(IVideoWindow *iface,
Michael Stefaniuca3269bd2009-03-11 00:31:26 +01001807 LONG *WindowStyleEx) {
Christian Costaf096fa32004-08-24 02:28:35 +00001808 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1809
Christian Costaacb2ff22005-06-13 11:37:55 +00001810 TRACE("(%p/%p)->(%p)\n", This, iface, WindowStyleEx);
1811
1812 *WindowStyleEx = GetWindowLongA(This->hWnd, GWL_EXSTYLE);
Christian Costaf096fa32004-08-24 02:28:35 +00001813
1814 return S_OK;
1815}
1816
1817static HRESULT WINAPI Videowindow_put_AutoShow(IVideoWindow *iface,
Michael Stefaniuca3269bd2009-03-11 00:31:26 +01001818 LONG AutoShow) {
Christian Costaf096fa32004-08-24 02:28:35 +00001819 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1820
Michael Stefaniuca3269bd2009-03-11 00:31:26 +01001821 TRACE("(%p/%p)->(%d)\n", This, iface, AutoShow);
Christian Costaacb2ff22005-06-13 11:37:55 +00001822
Christian Costac83e4f12008-12-29 12:00:10 +01001823 This->AutoShow = 1; /* FIXME: Should be AutoShow */;
Christian Costaf096fa32004-08-24 02:28:35 +00001824
1825 return S_OK;
1826}
1827
1828static HRESULT WINAPI Videowindow_get_AutoShow(IVideoWindow *iface,
Michael Stefaniuca3269bd2009-03-11 00:31:26 +01001829 LONG *AutoShow) {
Christian Costaf096fa32004-08-24 02:28:35 +00001830 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1831
Christian Costaacb2ff22005-06-13 11:37:55 +00001832 TRACE("(%p/%p)->(%p)\n", This, iface, AutoShow);
1833
1834 *AutoShow = This->AutoShow;
Christian Costaf096fa32004-08-24 02:28:35 +00001835
1836 return S_OK;
1837}
1838
1839static HRESULT WINAPI Videowindow_put_WindowState(IVideoWindow *iface,
Michael Stefaniuca3269bd2009-03-11 00:31:26 +01001840 LONG WindowState) {
Christian Costaf096fa32004-08-24 02:28:35 +00001841 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1842
Michael Stefaniuca3269bd2009-03-11 00:31:26 +01001843 FIXME("(%p/%p)->(%d): stub !!!\n", This, iface, WindowState);
Christian Costaf096fa32004-08-24 02:28:35 +00001844
1845 return S_OK;
1846}
1847
1848static HRESULT WINAPI Videowindow_get_WindowState(IVideoWindow *iface,
Michael Stefaniuca3269bd2009-03-11 00:31:26 +01001849 LONG *WindowState) {
Christian Costaf096fa32004-08-24 02:28:35 +00001850 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1851
Christian Costaacb2ff22005-06-13 11:37:55 +00001852 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, WindowState);
Christian Costaf096fa32004-08-24 02:28:35 +00001853
1854 return S_OK;
1855}
1856
1857static HRESULT WINAPI Videowindow_put_BackgroundPalette(IVideoWindow *iface,
Michael Stefaniuca3269bd2009-03-11 00:31:26 +01001858 LONG BackgroundPalette) {
Christian Costaf096fa32004-08-24 02:28:35 +00001859 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1860
Michael Stefaniuca3269bd2009-03-11 00:31:26 +01001861 FIXME("(%p/%p)->(%d): stub !!!\n", This, iface, BackgroundPalette);
Christian Costaf096fa32004-08-24 02:28:35 +00001862
1863 return S_OK;
1864}
1865
1866static HRESULT WINAPI Videowindow_get_BackgroundPalette(IVideoWindow *iface,
Michael Stefaniuca3269bd2009-03-11 00:31:26 +01001867 LONG *pBackgroundPalette) {
Christian Costaf096fa32004-08-24 02:28:35 +00001868 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1869
Christian Costaacb2ff22005-06-13 11:37:55 +00001870 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, pBackgroundPalette);
Christian Costaf096fa32004-08-24 02:28:35 +00001871
1872 return S_OK;
1873}
1874
1875static HRESULT WINAPI Videowindow_put_Visible(IVideoWindow *iface,
Michael Stefaniuca3269bd2009-03-11 00:31:26 +01001876 LONG Visible) {
Christian Costaf096fa32004-08-24 02:28:35 +00001877 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1878
Michael Stefaniuca3269bd2009-03-11 00:31:26 +01001879 TRACE("(%p/%p)->(%d)\n", This, iface, Visible);
Christian Costaacb2ff22005-06-13 11:37:55 +00001880
1881 ShowWindow(This->hWnd, Visible ? SW_SHOW : SW_HIDE);
Christian Costaf096fa32004-08-24 02:28:35 +00001882
1883 return S_OK;
1884}
1885
1886static HRESULT WINAPI Videowindow_get_Visible(IVideoWindow *iface,
Michael Stefaniuca3269bd2009-03-11 00:31:26 +01001887 LONG *pVisible) {
Christian Costaf096fa32004-08-24 02:28:35 +00001888 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1889
Christian Costaacb2ff22005-06-13 11:37:55 +00001890 TRACE("(%p/%p)->(%p)\n", This, iface, pVisible);
1891
1892 *pVisible = IsWindowVisible(This->hWnd);
Christian Costaf096fa32004-08-24 02:28:35 +00001893
1894 return S_OK;
1895}
1896
1897static HRESULT WINAPI Videowindow_put_Left(IVideoWindow *iface,
Michael Stefaniuca3269bd2009-03-11 00:31:26 +01001898 LONG Left) {
Christian Costaf096fa32004-08-24 02:28:35 +00001899 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1900
Michael Stefaniuca3269bd2009-03-11 00:31:26 +01001901 TRACE("(%p/%p)->(%d)\n", This, iface, Left);
Christian Costaacb2ff22005-06-13 11:37:55 +00001902
1903 if (!SetWindowPos(This->hWnd, NULL, Left, This->WindowPos.top, 0, 0, SWP_NOZORDER|SWP_NOSIZE))
1904 return E_FAIL;
1905
1906 This->WindowPos.left = Left;
Christian Costaf096fa32004-08-24 02:28:35 +00001907
1908 return S_OK;
1909}
1910
1911static HRESULT WINAPI Videowindow_get_Left(IVideoWindow *iface,
Michael Stefaniuca3269bd2009-03-11 00:31:26 +01001912 LONG *pLeft) {
Christian Costaf096fa32004-08-24 02:28:35 +00001913 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1914
Christian Costaacb2ff22005-06-13 11:37:55 +00001915 TRACE("(%p/%p)->(%p)\n", This, iface, pLeft);
1916
1917 *pLeft = This->WindowPos.left;
Christian Costaf096fa32004-08-24 02:28:35 +00001918
1919 return S_OK;
1920}
1921
1922static HRESULT WINAPI Videowindow_put_Width(IVideoWindow *iface,
Michael Stefaniuca3269bd2009-03-11 00:31:26 +01001923 LONG Width) {
Christian Costaf096fa32004-08-24 02:28:35 +00001924 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1925
Michael Stefaniuca3269bd2009-03-11 00:31:26 +01001926 TRACE("(%p/%p)->(%d)\n", This, iface, Width);
Christian Costaacb2ff22005-06-13 11:37:55 +00001927
1928 if (!SetWindowPos(This->hWnd, NULL, 0, 0, Width, This->WindowPos.bottom-This->WindowPos.top, SWP_NOZORDER|SWP_NOMOVE))
1929 return E_FAIL;
1930
1931 This->WindowPos.right = This->WindowPos.left + Width;
Christian Costaf096fa32004-08-24 02:28:35 +00001932
1933 return S_OK;
1934}
1935
1936static HRESULT WINAPI Videowindow_get_Width(IVideoWindow *iface,
Michael Stefaniuca3269bd2009-03-11 00:31:26 +01001937 LONG *pWidth) {
Christian Costaf096fa32004-08-24 02:28:35 +00001938 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1939
Christian Costaacb2ff22005-06-13 11:37:55 +00001940 TRACE("(%p/%p)->(%p)\n", This, iface, pWidth);
1941
1942 *pWidth = This->WindowPos.right - This->WindowPos.left;
Christian Costaf096fa32004-08-24 02:28:35 +00001943
1944 return S_OK;
1945}
1946
1947static HRESULT WINAPI Videowindow_put_Top(IVideoWindow *iface,
Michael Stefaniuca3269bd2009-03-11 00:31:26 +01001948 LONG Top) {
Christian Costaf096fa32004-08-24 02:28:35 +00001949 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1950
Michael Stefaniuca3269bd2009-03-11 00:31:26 +01001951 TRACE("(%p/%p)->(%d)\n", This, iface, Top);
Christian Costaacb2ff22005-06-13 11:37:55 +00001952
1953 if (!SetWindowPos(This->hWnd, NULL, This->WindowPos.left, Top, 0, 0, SWP_NOZORDER|SWP_NOSIZE))
1954 return E_FAIL;
1955
1956 This->WindowPos.top = Top;
Christian Costaf096fa32004-08-24 02:28:35 +00001957
1958 return S_OK;
1959}
1960
1961static HRESULT WINAPI Videowindow_get_Top(IVideoWindow *iface,
Michael Stefaniuca3269bd2009-03-11 00:31:26 +01001962 LONG *pTop) {
Christian Costaf096fa32004-08-24 02:28:35 +00001963 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1964
Christian Costaacb2ff22005-06-13 11:37:55 +00001965 TRACE("(%p/%p)->(%p)\n", This, iface, pTop);
1966
1967 *pTop = This->WindowPos.top;
Christian Costaf096fa32004-08-24 02:28:35 +00001968
1969 return S_OK;
1970}
1971
1972static HRESULT WINAPI Videowindow_put_Height(IVideoWindow *iface,
Michael Stefaniuca3269bd2009-03-11 00:31:26 +01001973 LONG Height) {
Christian Costaf096fa32004-08-24 02:28:35 +00001974 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1975
Michael Stefaniuca3269bd2009-03-11 00:31:26 +01001976 TRACE("(%p/%p)->(%d)\n", This, iface, Height);
Christian Costaacb2ff22005-06-13 11:37:55 +00001977
1978 if (!SetWindowPos(This->hWnd, NULL, 0, 0, This->WindowPos.right-This->WindowPos.left, Height, SWP_NOZORDER|SWP_NOMOVE))
1979 return E_FAIL;
1980
1981 This->WindowPos.bottom = This->WindowPos.top + Height;
Christian Costaf096fa32004-08-24 02:28:35 +00001982
1983 return S_OK;
1984}
1985
1986static HRESULT WINAPI Videowindow_get_Height(IVideoWindow *iface,
Michael Stefaniuca3269bd2009-03-11 00:31:26 +01001987 LONG *pHeight) {
Christian Costaf096fa32004-08-24 02:28:35 +00001988 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1989
Christian Costaacb2ff22005-06-13 11:37:55 +00001990 TRACE("(%p/%p)->(%p)\n", This, iface, pHeight);
1991
1992 *pHeight = This->WindowPos.bottom - This->WindowPos.top;
Christian Costaf096fa32004-08-24 02:28:35 +00001993
1994 return S_OK;
1995}
1996
1997static HRESULT WINAPI Videowindow_put_Owner(IVideoWindow *iface,
1998 OAHWND Owner) {
1999 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
2000
Hans Leidekkercfbb8592006-10-12 20:57:23 +02002001 TRACE("(%p/%p)->(%08x)\n", This, iface, (DWORD) Owner);
Christian Costaacb2ff22005-06-13 11:37:55 +00002002
2003 SetParent(This->hWnd, (HWND)Owner);
Christian Costaf096fa32004-08-24 02:28:35 +00002004
2005 return S_OK;
2006}
2007
2008static HRESULT WINAPI Videowindow_get_Owner(IVideoWindow *iface,
2009 OAHWND *Owner) {
2010 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
2011
Alexandre Julliard00140462009-01-08 13:17:49 +01002012 TRACE("(%p/%p)->(%p)\n", This, iface, Owner);
Christian Costaacb2ff22005-06-13 11:37:55 +00002013
2014 *(HWND*)Owner = GetParent(This->hWnd);
Christian Costaf096fa32004-08-24 02:28:35 +00002015
2016 return S_OK;
2017}
2018
2019static HRESULT WINAPI Videowindow_put_MessageDrain(IVideoWindow *iface,
2020 OAHWND Drain) {
2021 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
2022
Hans Leidekkercfbb8592006-10-12 20:57:23 +02002023 TRACE("(%p/%p)->(%08x)\n", This, iface, (DWORD) Drain);
Christian Costaacb2ff22005-06-13 11:37:55 +00002024
2025 This->hWndMsgDrain = (HWND)Drain;
Christian Costaf096fa32004-08-24 02:28:35 +00002026
2027 return S_OK;
2028}
2029
2030static HRESULT WINAPI Videowindow_get_MessageDrain(IVideoWindow *iface,
2031 OAHWND *Drain) {
2032 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
2033
Christian Costaacb2ff22005-06-13 11:37:55 +00002034 TRACE("(%p/%p)->(%p)\n", This, iface, Drain);
2035
2036 *Drain = (OAHWND)This->hWndMsgDrain;
Christian Costaf096fa32004-08-24 02:28:35 +00002037
2038 return S_OK;
2039}
2040
2041static HRESULT WINAPI Videowindow_get_BorderColor(IVideoWindow *iface,
Michael Stefaniuca3269bd2009-03-11 00:31:26 +01002042 LONG *Color) {
Christian Costaf096fa32004-08-24 02:28:35 +00002043 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
2044
Christian Costaacb2ff22005-06-13 11:37:55 +00002045 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, Color);
Christian Costaf096fa32004-08-24 02:28:35 +00002046
2047 return S_OK;
2048}
2049
2050static HRESULT WINAPI Videowindow_put_BorderColor(IVideoWindow *iface,
Michael Stefaniuca3269bd2009-03-11 00:31:26 +01002051 LONG Color) {
Christian Costaf096fa32004-08-24 02:28:35 +00002052 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
2053
Michael Stefaniuca3269bd2009-03-11 00:31:26 +01002054 FIXME("(%p/%p)->(%d): stub !!!\n", This, iface, Color);
Christian Costaf096fa32004-08-24 02:28:35 +00002055
2056 return S_OK;
2057}
2058
2059static HRESULT WINAPI Videowindow_get_FullScreenMode(IVideoWindow *iface,
Michael Stefaniuca3269bd2009-03-11 00:31:26 +01002060 LONG *FullScreenMode) {
Christian Costaf096fa32004-08-24 02:28:35 +00002061 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
2062
Christian Costaacb2ff22005-06-13 11:37:55 +00002063 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, FullScreenMode);
Christian Costaf096fa32004-08-24 02:28:35 +00002064
2065 return S_OK;
2066}
2067
2068static HRESULT WINAPI Videowindow_put_FullScreenMode(IVideoWindow *iface,
Michael Stefaniuca3269bd2009-03-11 00:31:26 +01002069 LONG FullScreenMode) {
Christian Costaf096fa32004-08-24 02:28:35 +00002070 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
2071
Michael Stefaniuca3269bd2009-03-11 00:31:26 +01002072 FIXME("(%p/%p)->(%d): stub !!!\n", This, iface, FullScreenMode);
Christian Costaf096fa32004-08-24 02:28:35 +00002073
2074 return S_OK;
2075}
2076
2077static HRESULT WINAPI Videowindow_SetWindowForeground(IVideoWindow *iface,
Michael Stefaniuca3269bd2009-03-11 00:31:26 +01002078 LONG Focus) {
Christian Costaf096fa32004-08-24 02:28:35 +00002079 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
Christian Costaacb2ff22005-06-13 11:37:55 +00002080 BOOL ret;
2081 IPin* pPin;
2082 HRESULT hr;
Christian Costaf096fa32004-08-24 02:28:35 +00002083
Michael Stefaniuca3269bd2009-03-11 00:31:26 +01002084 TRACE("(%p/%p)->(%d)\n", This, iface, Focus);
Christian Costaacb2ff22005-06-13 11:37:55 +00002085
2086 if ((Focus != FALSE) && (Focus != TRUE))
2087 return E_INVALIDARG;
2088
Maarten Lankhorst79349512008-04-25 14:25:49 -07002089 hr = IPin_ConnectedTo((IPin *)This->pInputPin, &pPin);
Christian Costaacb2ff22005-06-13 11:37:55 +00002090 if ((hr != S_OK) || !pPin)
2091 return VFW_E_NOT_CONNECTED;
2092
2093 if (Focus)
2094 ret = SetForegroundWindow(This->hWnd);
2095 else
2096 ret = SetWindowPos(This->hWnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
2097
2098 if (!ret)
2099 return E_FAIL;
Christian Costaf096fa32004-08-24 02:28:35 +00002100
2101 return S_OK;
2102}
2103
2104static HRESULT WINAPI Videowindow_NotifyOwnerMessage(IVideoWindow *iface,
2105 OAHWND hwnd,
Michael Stefaniuca3269bd2009-03-11 00:31:26 +01002106 LONG uMsg,
Christian Costaf096fa32004-08-24 02:28:35 +00002107 LONG_PTR wParam,
2108 LONG_PTR lParam) {
2109 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
2110
Michael Stefaniuca3269bd2009-03-11 00:31:26 +01002111 TRACE("(%p/%p)->(%08lx, %d, %08lx, %08lx)\n", This, iface, hwnd, uMsg, wParam, lParam);
Christian Costaf096fa32004-08-24 02:28:35 +00002112
Christian Costaacb2ff22005-06-13 11:37:55 +00002113 if (!PostMessageA(This->hWnd, uMsg, wParam, lParam))
2114 return E_FAIL;
2115
Christian Costaf096fa32004-08-24 02:28:35 +00002116 return S_OK;
2117}
2118
2119static HRESULT WINAPI Videowindow_SetWindowPosition(IVideoWindow *iface,
Michael Stefaniuca3269bd2009-03-11 00:31:26 +01002120 LONG Left,
2121 LONG Top,
2122 LONG Width,
2123 LONG Height) {
Christian Costaf096fa32004-08-24 02:28:35 +00002124 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
Michael Stefaniuca3269bd2009-03-11 00:31:26 +01002125
2126 TRACE("(%p/%p)->(%d, %d, %d, %d)\n", This, iface, Left, Top, Width, Height);
Christian Costaf096fa32004-08-24 02:28:35 +00002127
Christian Costaacb2ff22005-06-13 11:37:55 +00002128 if (!SetWindowPos(This->hWnd, NULL, Left, Top, Width, Height, SWP_NOZORDER))
2129 return E_FAIL;
2130
2131 This->WindowPos.left = Left;
2132 This->WindowPos.top = Top;
2133 This->WindowPos.right = Left + Width;
2134 This->WindowPos.bottom = Top + Height;
2135
Christian Costaf096fa32004-08-24 02:28:35 +00002136 return S_OK;
2137}
2138
2139static HRESULT WINAPI Videowindow_GetWindowPosition(IVideoWindow *iface,
Michael Stefaniuca3269bd2009-03-11 00:31:26 +01002140 LONG *pLeft,
2141 LONG *pTop,
2142 LONG *pWidth,
2143 LONG *pHeight) {
Christian Costaf096fa32004-08-24 02:28:35 +00002144 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
2145
Christian Costaacb2ff22005-06-13 11:37:55 +00002146 TRACE("(%p/%p)->(%p, %p, %p, %p)\n", This, iface, pLeft, pTop, pWidth, pHeight);
2147
2148 *pLeft = This->WindowPos.left;
2149 *pTop = This->WindowPos.top;
2150 *pWidth = This->WindowPos.right - This->WindowPos.left;
2151 *pHeight = This->WindowPos.bottom - This->WindowPos.top;
Christian Costaf096fa32004-08-24 02:28:35 +00002152
2153 return S_OK;
2154}
2155
2156static HRESULT WINAPI Videowindow_GetMinIdealImageSize(IVideoWindow *iface,
Michael Stefaniuca3269bd2009-03-11 00:31:26 +01002157 LONG *pWidth,
2158 LONG *pHeight) {
Christian Costaf096fa32004-08-24 02:28:35 +00002159 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
2160
Christian Costaacb2ff22005-06-13 11:37:55 +00002161 FIXME("(%p/%p)->(%p, %p): semi stub !!!\n", This, iface, pWidth, pHeight);
2162
2163 *pWidth = This->VideoWidth;
2164 *pHeight = This->VideoHeight;
Christian Costaf096fa32004-08-24 02:28:35 +00002165
2166 return S_OK;
2167}
2168
2169static HRESULT WINAPI Videowindow_GetMaxIdealImageSize(IVideoWindow *iface,
Michael Stefaniuca3269bd2009-03-11 00:31:26 +01002170 LONG *pWidth,
2171 LONG *pHeight) {
Christian Costaf096fa32004-08-24 02:28:35 +00002172 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
2173
Christian Costaacb2ff22005-06-13 11:37:55 +00002174 FIXME("(%p/%p)->(%p, %p): semi stub !!!\n", This, iface, pWidth, pHeight);
2175
2176 *pWidth = This->VideoWidth;
2177 *pHeight = This->VideoHeight;
Christian Costaf096fa32004-08-24 02:28:35 +00002178
2179 return S_OK;
2180}
2181
2182static HRESULT WINAPI Videowindow_GetRestorePosition(IVideoWindow *iface,
Michael Stefaniuca3269bd2009-03-11 00:31:26 +01002183 LONG *pLeft,
2184 LONG *pTop,
2185 LONG *pWidth,
2186 LONG *pHeight) {
Christian Costaf096fa32004-08-24 02:28:35 +00002187 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
2188
Christian Costaacb2ff22005-06-13 11:37:55 +00002189 FIXME("(%p/%p)->(%p, %p, %p, %p): stub !!!\n", This, iface, pLeft, pTop, pWidth, pHeight);
Christian Costaf096fa32004-08-24 02:28:35 +00002190
2191 return S_OK;
2192}
2193
2194static HRESULT WINAPI Videowindow_HideCursor(IVideoWindow *iface,
Michael Stefaniuca3269bd2009-03-11 00:31:26 +01002195 LONG HideCursor) {
Christian Costaf096fa32004-08-24 02:28:35 +00002196 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
2197
Michael Stefaniuca3269bd2009-03-11 00:31:26 +01002198 FIXME("(%p/%p)->(%d): stub !!!\n", This, iface, HideCursor);
Christian Costaf096fa32004-08-24 02:28:35 +00002199
2200 return S_OK;
2201}
2202
2203static HRESULT WINAPI Videowindow_IsCursorHidden(IVideoWindow *iface,
Michael Stefaniuca3269bd2009-03-11 00:31:26 +01002204 LONG *CursorHidden) {
Christian Costaf096fa32004-08-24 02:28:35 +00002205 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
2206
Christian Costaacb2ff22005-06-13 11:37:55 +00002207 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, CursorHidden);
Christian Costaf096fa32004-08-24 02:28:35 +00002208
2209 return S_OK;
2210}
2211
Dmitry Timoshkoveba47f12005-06-06 19:50:35 +00002212static const IVideoWindowVtbl IVideoWindow_VTable =
Christian Costaf096fa32004-08-24 02:28:35 +00002213{
2214 Videowindow_QueryInterface,
2215 Videowindow_AddRef,
2216 Videowindow_Release,
2217 Videowindow_GetTypeInfoCount,
2218 Videowindow_GetTypeInfo,
2219 Videowindow_GetIDsOfNames,
2220 Videowindow_Invoke,
2221 Videowindow_put_Caption,
2222 Videowindow_get_Caption,
2223 Videowindow_put_WindowStyle,
2224 Videowindow_get_WindowStyle,
2225 Videowindow_put_WindowStyleEx,
2226 Videowindow_get_WindowStyleEx,
2227 Videowindow_put_AutoShow,
2228 Videowindow_get_AutoShow,
2229 Videowindow_put_WindowState,
2230 Videowindow_get_WindowState,
2231 Videowindow_put_BackgroundPalette,
2232 Videowindow_get_BackgroundPalette,
2233 Videowindow_put_Visible,
2234 Videowindow_get_Visible,
2235 Videowindow_put_Left,
2236 Videowindow_get_Left,
2237 Videowindow_put_Width,
2238 Videowindow_get_Width,
2239 Videowindow_put_Top,
2240 Videowindow_get_Top,
2241 Videowindow_put_Height,
2242 Videowindow_get_Height,
2243 Videowindow_put_Owner,
2244 Videowindow_get_Owner,
2245 Videowindow_put_MessageDrain,
2246 Videowindow_get_MessageDrain,
2247 Videowindow_get_BorderColor,
2248 Videowindow_put_BorderColor,
2249 Videowindow_get_FullScreenMode,
2250 Videowindow_put_FullScreenMode,
2251 Videowindow_SetWindowForeground,
2252 Videowindow_NotifyOwnerMessage,
2253 Videowindow_SetWindowPosition,
2254 Videowindow_GetWindowPosition,
2255 Videowindow_GetMinIdealImageSize,
2256 Videowindow_GetMaxIdealImageSize,
2257 Videowindow_GetRestorePosition,
2258 Videowindow_HideCursor,
2259 Videowindow_IsCursorHidden
2260};