blob: a7df440cff73165573246200267efd65dd4f5867 [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"
30#include "mmreg.h"
31#include "vfwmsgs.h"
32#include "amvideo.h"
33#include "fourcc.h"
34#include "windef.h"
35#include "winbase.h"
36#include "dshow.h"
Christian Costa7dea79c2005-03-02 10:12:12 +000037#include "evcode.h"
Christian Costaf096fa32004-08-24 02:28:35 +000038#include "strmif.h"
39#include "ddraw.h"
40
41#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;
Dmitry Timoshkoveba47f12005-06-06 19:50:35 +000051static const IBasicVideoVtbl IBasicVideo_VTable;
52static const IVideoWindowVtbl IVideoWindow_VTable;
Christian Costaf096fa32004-08-24 02:28:35 +000053static const IPinVtbl VideoRenderer_InputPin_Vtbl;
54
55typedef struct VideoRendererImpl
56{
57 const IBaseFilterVtbl * lpVtbl;
Dmitry Timoshkoveba47f12005-06-06 19:50:35 +000058 const IBasicVideoVtbl * IBasicVideo_vtbl;
59 const IVideoWindowVtbl * IVideoWindow_vtbl;
Christian Costaf096fa32004-08-24 02:28:35 +000060
Mike McCormack0791d062005-07-12 19:21:36 +000061 LONG refCount;
Christian Costaf096fa32004-08-24 02:28:35 +000062 CRITICAL_SECTION csFilter;
63 FILTER_STATE state;
64 REFERENCE_TIME rtStreamStart;
65 IReferenceClock * pClock;
66 FILTER_INFO filterInfo;
67
68 InputPin * pInputPin;
69 IPin ** ppPins;
70
Christian Costaacb2ff22005-06-13 11:37:55 +000071 BOOL init;
72 HANDLE hThread;
73 DWORD ThreadID;
74 HANDLE hEvent;
75 BOOL ThreadResult;
76 HWND hWnd;
77 HWND hWndMsgDrain;
78 BOOL AutoShow;
79 RECT SourceRect;
80 RECT DestRect;
81 RECT WindowPos;
82 long VideoWidth;
83 long VideoHeight;
Christian Costaf096fa32004-08-24 02:28:35 +000084} VideoRendererImpl;
85
Christian Costaacb2ff22005-06-13 11:37:55 +000086static LRESULT CALLBACK VideoWndProcA(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
87{
88 VideoRendererImpl* pVideoRenderer = (VideoRendererImpl*)GetWindowLongA(hwnd, 0);
89 LPRECT lprect = (LPRECT)lParam;
90
91 if (pVideoRenderer && pVideoRenderer->hWndMsgDrain)
92 {
93 switch(uMsg)
94 {
95 case WM_KEYDOWN:
96 case WM_KEYUP:
97 case WM_LBUTTONDBLCLK:
98 case WM_LBUTTONDOWN:
99 case WM_LBUTTONUP:
100 case WM_MBUTTONDBLCLK:
101 case WM_MBUTTONDOWN:
102 case WM_MBUTTONUP:
103 case WM_MOUSEACTIVATE:
104 case WM_MOUSEMOVE:
105 case WM_NCLBUTTONDBLCLK:
106 case WM_NCLBUTTONDOWN:
107 case WM_NCLBUTTONUP:
108 case WM_NCMBUTTONDBLCLK:
109 case WM_NCMBUTTONDOWN:
110 case WM_NCMBUTTONUP:
111 case WM_NCMOUSEMOVE:
112 case WM_NCRBUTTONDBLCLK:
113 case WM_NCRBUTTONDOWN:
114 case WM_NCRBUTTONUP:
115 case WM_RBUTTONDBLCLK:
116 case WM_RBUTTONDOWN:
117 case WM_RBUTTONUP:
118 PostMessageA(pVideoRenderer->hWndMsgDrain, uMsg, wParam, lParam);
119 break;
120 default:
121 break;
122 }
123 }
124
125 switch(uMsg)
126 {
127 case WM_SIZING:
Hans Leidekkercfbb8592006-10-12 20:57:23 +0200128 /* TRACE("WM_SIZING %d %d %d %d\n", lprect->left, lprect->top, lprect->right, lprect->bottom); */
Christian Costaacb2ff22005-06-13 11:37:55 +0000129 SetWindowPos(hwnd, NULL, lprect->left, lprect->top, lprect->right - lprect->left, lprect->bottom - lprect->top, SWP_NOZORDER);
130 GetClientRect(hwnd, &pVideoRenderer->DestRect);
131 return TRUE;
132 default:
133 return DefWindowProcA(hwnd, uMsg, wParam, lParam);
134 }
135 return 0;
136}
137
138static BOOL CreateRenderingWindow(VideoRendererImpl* This)
139{
140 WNDCLASSA winclass;
141
142 TRACE("(%p)->()\n", This);
143
144 winclass.style = 0;
145 winclass.lpfnWndProc = VideoWndProcA;
146 winclass.cbClsExtra = 0;
147 winclass.cbWndExtra = sizeof(VideoRendererImpl*);
148 winclass.hInstance = NULL;
149 winclass.hIcon = NULL;
150 winclass.hCursor = NULL;
Christian Costab82d94e2005-10-10 10:44:54 +0000151 winclass.hbrBackground = GetStockObject(BLACK_BRUSH);
Christian Costaacb2ff22005-06-13 11:37:55 +0000152 winclass.lpszMenuName = NULL;
153 winclass.lpszClassName = "Wine ActiveMovie Class";
154
155 if (!wnd_class_registered)
156 {
157 if (!RegisterClassA(&winclass))
158 {
Francois Gouget4fb03d92007-01-05 13:05:20 +0100159 ERR("Unable to register window %u\n", GetLastError());
Christian Costaacb2ff22005-06-13 11:37:55 +0000160 return FALSE;
161 }
162 wnd_class_registered = TRUE;
163 }
164
165 This->hWnd = CreateWindowExA(0, "Wine ActiveMovie Class", "Wine ActiveMovie Window", WS_SIZEBOX,
166 CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL,
167 NULL, NULL, NULL);
168
169 if (!This->hWnd)
170 {
171 ERR("Unable to create window\n");
172 return FALSE;
173 }
174
175 SetWindowLongA(This->hWnd, 0, (LONG)This);
176
177 return TRUE;
178}
179
180static DWORD WINAPI MessageLoop(LPVOID lpParameter)
181{
182 VideoRendererImpl* This = (VideoRendererImpl*) lpParameter;
183 MSG msg;
184 BOOL fGotMessage;
185
186 TRACE("Starting message loop\n");
187
188 if (!CreateRenderingWindow(This))
189 {
190 This->ThreadResult = FALSE;
191 SetEvent(This->hEvent);
192 return 0;
193 }
194
195 This->ThreadResult = TRUE;
196 SetEvent(This->hEvent);
197
Francois Gouget77065602005-06-17 20:55:27 +0000198 while ((fGotMessage = GetMessageA(&msg, NULL, 0, 0)) != 0 && fGotMessage != -1)
Christian Costaacb2ff22005-06-13 11:37:55 +0000199 {
200 TranslateMessage(&msg);
201 DispatchMessageA(&msg);
202 }
203
204 TRACE("End of message loop\n");
205
206 return msg.wParam;
207}
208
209static BOOL CreateRenderingSubsystem(VideoRendererImpl* This)
210{
211 This->hEvent = CreateEventW(NULL, FALSE, FALSE, NULL);
212 if (!This->hEvent)
213 return FALSE;
214
215 This->hThread = CreateThread(NULL, 0, MessageLoop, (LPVOID)This, 0, &This->ThreadID);
216 if (!This->hThread)
217 {
218 CloseHandle(This->hEvent);
219 return FALSE;
220 }
221
222 WaitForSingleObject(This->hEvent, INFINITE);
223 CloseHandle(This->hEvent);
224
225 if (!This->ThreadResult)
226 {
227 CloseHandle(This->hThread);
228 return FALSE;
229 }
230
231 return TRUE;
232}
233
Christian Costaf096fa32004-08-24 02:28:35 +0000234static const IMemInputPinVtbl MemInputPin_Vtbl =
235{
236 MemInputPin_QueryInterface,
237 MemInputPin_AddRef,
238 MemInputPin_Release,
239 MemInputPin_GetAllocator,
240 MemInputPin_NotifyAllocator,
241 MemInputPin_GetAllocatorRequirements,
242 MemInputPin_Receive,
243 MemInputPin_ReceiveMultiple,
244 MemInputPin_ReceiveCanBlock
245};
246
247static HRESULT VideoRenderer_InputPin_Construct(const PIN_INFO * pPinInfo, SAMPLEPROC pSampleProc, LPVOID pUserData, QUERYACCEPTPROC pQueryAccept, LPCRITICAL_SECTION pCritSec, IPin ** ppPin)
248{
249 InputPin * pPinImpl;
250
251 *ppPin = NULL;
252
253 if (pPinInfo->dir != PINDIR_INPUT)
254 {
255 ERR("Pin direction(%x) != PINDIR_INPUT\n", pPinInfo->dir);
256 return E_INVALIDARG;
257 }
258
259 pPinImpl = CoTaskMemAlloc(sizeof(*pPinImpl));
260
261 if (!pPinImpl)
262 return E_OUTOFMEMORY;
263
264 if (SUCCEEDED(InputPin_Init(pPinInfo, pSampleProc, pUserData, pQueryAccept, pCritSec, pPinImpl)))
265 {
266 pPinImpl->pin.lpVtbl = &VideoRenderer_InputPin_Vtbl;
267 pPinImpl->lpVtblMemInput = &MemInputPin_Vtbl;
268
269 *ppPin = (IPin *)(&pPinImpl->pin.lpVtbl);
270 return S_OK;
271 }
272 return E_FAIL;
273}
274
Christian Costaf096fa32004-08-24 02:28:35 +0000275static DWORD VideoRenderer_SendSampleData(VideoRendererImpl* This, LPBYTE data, DWORD size)
276{
277 VIDEOINFOHEADER* format;
278 AM_MEDIA_TYPE amt;
279 HRESULT hr = S_OK;
Christian Costaf096fa32004-08-24 02:28:35 +0000280 DDSURFACEDESC sdesc;
281 int width;
282 int height;
283 LPBYTE palette = NULL;
Christian Costaacb2ff22005-06-13 11:37:55 +0000284 HDC hDC;
Christian Costaf096fa32004-08-24 02:28:35 +0000285
Hans Leidekkercfbb8592006-10-12 20:57:23 +0200286 TRACE("%p %p %d\n", This, data, size);
Christian Costaf096fa32004-08-24 02:28:35 +0000287
288 sdesc.dwSize = sizeof(sdesc);
289 hr = IPin_ConnectionMediaType(This->ppPins[0], &amt);
290 if (FAILED(hr)) {
Christian Costaacb2ff22005-06-13 11:37:55 +0000291 ERR("Unable to retrieve media type\n");
292 return hr;
Christian Costaf096fa32004-08-24 02:28:35 +0000293 }
294 format = (VIDEOINFOHEADER*)amt.pbFormat;
295
Hans Leidekkercfbb8592006-10-12 20:57:23 +0200296 TRACE("biSize = %d\n", format->bmiHeader.biSize);
297 TRACE("biWidth = %d\n", format->bmiHeader.biWidth);
Francois Gouget30e44c82006-11-07 00:37:42 +0100298 TRACE("biHeight = %d\n", format->bmiHeader.biHeight);
Christian Costaf096fa32004-08-24 02:28:35 +0000299 TRACE("biPlanes = %d\n", format->bmiHeader.biPlanes);
300 TRACE("biBitCount = %d\n", format->bmiHeader.biBitCount);
301 TRACE("biCompression = %s\n", debugstr_an((LPSTR)&(format->bmiHeader.biCompression), 4));
Hans Leidekkercfbb8592006-10-12 20:57:23 +0200302 TRACE("biSizeImage = %d\n", format->bmiHeader.biSizeImage);
Christian Costaf096fa32004-08-24 02:28:35 +0000303
304 width = format->bmiHeader.biWidth;
305 height = format->bmiHeader.biHeight;
306 palette = ((LPBYTE)&format->bmiHeader) + format->bmiHeader.biSize;
307
Christian Costaacb2ff22005-06-13 11:37:55 +0000308 if (!This->init)
Christian Costaf096fa32004-08-24 02:28:35 +0000309 {
Christian Costaacb2ff22005-06-13 11:37:55 +0000310 /* Compute the size of the whole window so the client area size matches video one */
311 RECT wrect, crect;
312 int h, v;
313 GetWindowRect(This->hWnd, &wrect);
314 GetClientRect(This->hWnd, &crect);
315 h = (wrect.right - wrect.left) - (crect.right - crect.left);
316 v = (wrect.bottom - wrect.top) - (crect.bottom - crect.top);
317 SetWindowPos(This->hWnd, NULL, 0, 0, width + h +20, height + v+20, SWP_NOZORDER|SWP_NOMOVE);
318 This->WindowPos.left = 0;
319 This->WindowPos.top = 0;
320 This->WindowPos.right = width;
Robert Shearman7d6dbed2006-08-28 14:18:07 +0100321 This->WindowPos.bottom = abs(height);
Christian Costaacb2ff22005-06-13 11:37:55 +0000322 GetClientRect(This->hWnd, &This->DestRect);
323 This->init = TRUE;
Christian Costaf096fa32004-08-24 02:28:35 +0000324 }
325
Christian Costaacb2ff22005-06-13 11:37:55 +0000326 hDC = GetDC(This->hWnd);
327
328 if (!hDC) {
329 ERR("Cannot get DC from window!\n");
330 return E_FAIL;
Christian Costaf096fa32004-08-24 02:28:35 +0000331 }
Christian Costaacb2ff22005-06-13 11:37:55 +0000332
Hans Leidekkercfbb8592006-10-12 20:57:23 +0200333 TRACE("Src Rect: %d %d %d %d\n", This->SourceRect.left, This->SourceRect.top, This->SourceRect.right, This->SourceRect.bottom);
334 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 +0000335
336 StretchDIBits(hDC, This->DestRect.left, This->DestRect.top, This->DestRect.right -This->DestRect.left,
337 This->DestRect.bottom - This->DestRect.top, This->SourceRect.left, This->SourceRect.top,
338 This->SourceRect.right - This->SourceRect.left, This->SourceRect.bottom - This->SourceRect.top,
Christian Costa19f9da82005-08-17 09:51:57 +0000339 data, (BITMAPINFO*)&format->bmiHeader, DIB_RGB_COLORS, SRCCOPY);
Christian Costaacb2ff22005-06-13 11:37:55 +0000340
341 ReleaseDC(This->hWnd, hDC);
Christian Costaf096fa32004-08-24 02:28:35 +0000342
Christian Costaacb2ff22005-06-13 11:37:55 +0000343 if (This->AutoShow)
344 ShowWindow(This->hWnd, SW_SHOW);
345
Christian Costaf096fa32004-08-24 02:28:35 +0000346 return S_OK;
347}
348
349static HRESULT VideoRenderer_Sample(LPVOID iface, IMediaSample * pSample)
350{
Alexandre Julliardf5f7a182004-09-08 01:50:37 +0000351 VideoRendererImpl *This = (VideoRendererImpl *)iface;
Christian Costaf096fa32004-08-24 02:28:35 +0000352 LPBYTE pbSrcStream = NULL;
353 long cbSrcStream = 0;
354 REFERENCE_TIME tStart, tStop;
355 HRESULT hr;
356
357 TRACE("%p %p\n", iface, pSample);
358
359 hr = IMediaSample_GetPointer(pSample, &pbSrcStream);
360 if (FAILED(hr))
361 {
Hans Leidekkercfbb8592006-10-12 20:57:23 +0200362 ERR("Cannot get pointer to sample data (%x)\n", hr);
Christian Costaacb2ff22005-06-13 11:37:55 +0000363 return hr;
Christian Costaf096fa32004-08-24 02:28:35 +0000364 }
365
366 hr = IMediaSample_GetTime(pSample, &tStart, &tStop);
367 if (FAILED(hr))
Hans Leidekkercfbb8592006-10-12 20:57:23 +0200368 ERR("Cannot get sample time (%x)\n", hr);
Christian Costaf096fa32004-08-24 02:28:35 +0000369
370 cbSrcStream = IMediaSample_GetActualDataLength(pSample);
371
372 TRACE("val %p %ld\n", pbSrcStream, cbSrcStream);
373
374#if 0 /* For debugging purpose */
375 {
376 int i;
377 for(i = 0; i < cbSrcStream; i++)
378 {
Christian Costaacb2ff22005-06-13 11:37:55 +0000379 if ((i!=0) && !(i%16))
Alexandre Julliard9f859692005-09-25 15:23:21 +0000380 TRACE("\n");
381 TRACE("%02x ", pbSrcStream[i]);
Christian Costaf096fa32004-08-24 02:28:35 +0000382 }
Alexandre Julliard9f859692005-09-25 15:23:21 +0000383 TRACE("\n");
Christian Costaf096fa32004-08-24 02:28:35 +0000384 }
385#endif
386
Christian Costaf096fa32004-08-24 02:28:35 +0000387 VideoRenderer_SendSampleData(This, pbSrcStream, cbSrcStream);
388
Christian Costaf096fa32004-08-24 02:28:35 +0000389 return S_OK;
390}
391
392static HRESULT VideoRenderer_QueryAccept(LPVOID iface, const AM_MEDIA_TYPE * pmt)
393{
Christian Costab82d94e2005-10-10 10:44:54 +0000394 if (!IsEqualIID(&pmt->majortype, &MEDIATYPE_Video))
395 return S_FALSE;
396
397 if (IsEqualIID(&pmt->subtype, &MEDIASUBTYPE_RGB32) ||
398 IsEqualIID(&pmt->subtype, &MEDIASUBTYPE_RGB24) ||
399 IsEqualIID(&pmt->subtype, &MEDIASUBTYPE_RGB565) ||
400 IsEqualIID(&pmt->subtype, &MEDIASUBTYPE_RGB8))
Christian Costaacb2ff22005-06-13 11:37:55 +0000401 {
402 VideoRendererImpl* This = (VideoRendererImpl*) iface;
403 VIDEOINFOHEADER* format = (VIDEOINFOHEADER*)pmt->pbFormat;
Christian Costab82d94e2005-10-10 10:44:54 +0000404
405 if (!IsEqualIID(&pmt->formattype, &FORMAT_VideoInfo))
406 {
407 WARN("Format type %s not supported\n", debugstr_guid(&pmt->formattype));
408 return S_FALSE;
409 }
Christian Costaacb2ff22005-06-13 11:37:55 +0000410 This->SourceRect.left = 0;
411 This->SourceRect.top = 0;
412 This->SourceRect.right = This->VideoWidth = format->bmiHeader.biWidth;
413 This->SourceRect.bottom = This->VideoHeight = format->bmiHeader.biHeight;
Christian Costaf096fa32004-08-24 02:28:35 +0000414 return S_OK;
Christian Costaacb2ff22005-06-13 11:37:55 +0000415 }
Christian Costaf096fa32004-08-24 02:28:35 +0000416 return S_FALSE;
417}
418
419HRESULT VideoRenderer_create(IUnknown * pUnkOuter, LPVOID * ppv)
420{
421 HRESULT hr;
422 PIN_INFO piInput;
423 VideoRendererImpl * pVideoRenderer;
424
425 TRACE("(%p, %p)\n", pUnkOuter, ppv);
426
427 *ppv = NULL;
428
429 if (pUnkOuter)
430 return CLASS_E_NOAGGREGATION;
431
432 pVideoRenderer = CoTaskMemAlloc(sizeof(VideoRendererImpl));
433
434 pVideoRenderer->lpVtbl = &VideoRenderer_Vtbl;
435 pVideoRenderer->IBasicVideo_vtbl = &IBasicVideo_VTable;
436 pVideoRenderer->IVideoWindow_vtbl = &IVideoWindow_VTable;
437
438 pVideoRenderer->refCount = 1;
439 InitializeCriticalSection(&pVideoRenderer->csFilter);
Jan Zerebeckib5619e82007-03-10 22:10:20 +0100440 pVideoRenderer->csFilter.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": VideoRendererImpl.csFilter");
Christian Costaf096fa32004-08-24 02:28:35 +0000441 pVideoRenderer->state = State_Stopped;
442 pVideoRenderer->pClock = NULL;
443 pVideoRenderer->init = 0;
Christian Costaacb2ff22005-06-13 11:37:55 +0000444 pVideoRenderer->AutoShow = 1;
Christian Costaf096fa32004-08-24 02:28:35 +0000445 ZeroMemory(&pVideoRenderer->filterInfo, sizeof(FILTER_INFO));
446
447 pVideoRenderer->ppPins = CoTaskMemAlloc(1 * sizeof(IPin *));
448
449 /* construct input pin */
450 piInput.dir = PINDIR_INPUT;
451 piInput.pFilter = (IBaseFilter *)pVideoRenderer;
Peter Berg Larsene732fc02005-03-28 14:17:51 +0000452 lstrcpynW(piInput.achName, wcsInputPinName, sizeof(piInput.achName) / sizeof(piInput.achName[0]));
Christian Costaf096fa32004-08-24 02:28:35 +0000453
454 hr = VideoRenderer_InputPin_Construct(&piInput, VideoRenderer_Sample, (LPVOID)pVideoRenderer, VideoRenderer_QueryAccept, &pVideoRenderer->csFilter, (IPin **)&pVideoRenderer->pInputPin);
455
456 if (SUCCEEDED(hr))
457 {
458 pVideoRenderer->ppPins[0] = (IPin *)pVideoRenderer->pInputPin;
459 *ppv = (LPVOID)pVideoRenderer;
460 }
461 else
462 {
463 CoTaskMemFree(pVideoRenderer->ppPins);
Jan Zerebeckib5619e82007-03-10 22:10:20 +0100464 pVideoRenderer->csFilter.DebugInfo->Spare[0] = 0;
Christian Costaf096fa32004-08-24 02:28:35 +0000465 DeleteCriticalSection(&pVideoRenderer->csFilter);
466 CoTaskMemFree(pVideoRenderer);
467 }
468
Christian Costaacb2ff22005-06-13 11:37:55 +0000469 if (!CreateRenderingSubsystem(pVideoRenderer))
470 return E_FAIL;
471
Christian Costaf096fa32004-08-24 02:28:35 +0000472 return hr;
473}
474
475static HRESULT WINAPI VideoRenderer_QueryInterface(IBaseFilter * iface, REFIID riid, LPVOID * ppv)
476{
Alexandre Julliardf5f7a182004-09-08 01:50:37 +0000477 VideoRendererImpl *This = (VideoRendererImpl *)iface;
Christian Costaf096fa32004-08-24 02:28:35 +0000478 TRACE("(%p/%p)->(%s, %p)\n", This, iface, qzdebugstr_guid(riid), ppv);
479
480 *ppv = NULL;
481
482 if (IsEqualIID(riid, &IID_IUnknown))
483 *ppv = (LPVOID)This;
484 else if (IsEqualIID(riid, &IID_IPersist))
485 *ppv = (LPVOID)This;
486 else if (IsEqualIID(riid, &IID_IMediaFilter))
487 *ppv = (LPVOID)This;
488 else if (IsEqualIID(riid, &IID_IBaseFilter))
489 *ppv = (LPVOID)This;
490 else if (IsEqualIID(riid, &IID_IBasicVideo))
491 *ppv = (LPVOID)&(This->IBasicVideo_vtbl);
492 else if (IsEqualIID(riid, &IID_IVideoWindow))
493 *ppv = (LPVOID)&(This->IVideoWindow_vtbl);
494
495 if (*ppv)
496 {
497 IUnknown_AddRef((IUnknown *)(*ppv));
498 return S_OK;
499 }
500
501 FIXME("No interface for %s!\n", qzdebugstr_guid(riid));
502
503 return E_NOINTERFACE;
504}
505
506static ULONG WINAPI VideoRenderer_AddRef(IBaseFilter * iface)
507{
Alexandre Julliardf5f7a182004-09-08 01:50:37 +0000508 VideoRendererImpl *This = (VideoRendererImpl *)iface;
Paul Vriensc6559a12005-01-06 19:36:47 +0000509 ULONG refCount = InterlockedIncrement(&This->refCount);
Christian Costa9b8d5c62004-12-27 17:15:58 +0000510
Hans Leidekkercfbb8592006-10-12 20:57:23 +0200511 TRACE("(%p/%p)->() AddRef from %d\n", This, iface, refCount - 1);
Christian Costa9b8d5c62004-12-27 17:15:58 +0000512
Paul Vriensc6559a12005-01-06 19:36:47 +0000513 return refCount;
Christian Costaf096fa32004-08-24 02:28:35 +0000514}
515
516static ULONG WINAPI VideoRenderer_Release(IBaseFilter * iface)
517{
Alexandre Julliardf5f7a182004-09-08 01:50:37 +0000518 VideoRendererImpl *This = (VideoRendererImpl *)iface;
Paul Vriensc6559a12005-01-06 19:36:47 +0000519 ULONG refCount = InterlockedDecrement(&This->refCount);
Christian Costa9b8d5c62004-12-27 17:15:58 +0000520
Hans Leidekkercfbb8592006-10-12 20:57:23 +0200521 TRACE("(%p/%p)->() Release from %d\n", This, iface, refCount + 1);
Christian Costa9b8d5c62004-12-27 17:15:58 +0000522
Paul Vriensc6559a12005-01-06 19:36:47 +0000523 if (!refCount)
Christian Costaf096fa32004-08-24 02:28:35 +0000524 {
Chris Robinson809f6842007-03-13 10:47:47 -0700525 IPin *pConnectedTo;
526
Christian Costaacb2ff22005-06-13 11:37:55 +0000527 DestroyWindow(This->hWnd);
528 PostThreadMessageA(This->ThreadID, WM_QUIT, 0, 0);
529 WaitForSingleObject(This->hThread, INFINITE);
530 CloseHandle(This->hThread);
531
Christian Costacb6e4a12005-06-04 09:37:35 +0000532 if (This->pClock)
533 IReferenceClock_Release(This->pClock);
Christian Costaf096fa32004-08-24 02:28:35 +0000534
Chris Robinson809f6842007-03-13 10:47:47 -0700535 if (SUCCEEDED(IPin_ConnectedTo(This->ppPins[0], &pConnectedTo)))
536 {
537 IPin_Disconnect(pConnectedTo);
538 IPin_Release(pConnectedTo);
539 }
540 IPin_Disconnect(This->ppPins[0]);
541
Christian Costaf096fa32004-08-24 02:28:35 +0000542 IPin_Release(This->ppPins[0]);
543
Chris Robinson04527062007-03-08 03:03:06 -0800544 CoTaskMemFree(This->ppPins);
Christian Costaf096fa32004-08-24 02:28:35 +0000545 This->lpVtbl = NULL;
546
Chris Robinson6bd3b152007-03-19 13:26:09 -0700547 This->csFilter.DebugInfo->Spare[0] = 0;
548 DeleteCriticalSection(&This->csFilter);
549
Christian Costaf096fa32004-08-24 02:28:35 +0000550 TRACE("Destroying Video Renderer\n");
551 CoTaskMemFree(This);
552
553 return 0;
554 }
555 else
Paul Vriensc6559a12005-01-06 19:36:47 +0000556 return refCount;
Christian Costaf096fa32004-08-24 02:28:35 +0000557}
558
559/** IPersist methods **/
560
561static HRESULT WINAPI VideoRenderer_GetClassID(IBaseFilter * iface, CLSID * pClsid)
562{
Alexandre Julliardf5f7a182004-09-08 01:50:37 +0000563 VideoRendererImpl *This = (VideoRendererImpl *)iface;
Christian Costaf096fa32004-08-24 02:28:35 +0000564
565 TRACE("(%p/%p)->(%p)\n", This, iface, pClsid);
566
567 *pClsid = CLSID_VideoRenderer;
568
569 return S_OK;
570}
571
572/** IMediaFilter methods **/
573
574static HRESULT WINAPI VideoRenderer_Stop(IBaseFilter * iface)
575{
Alexandre Julliardf5f7a182004-09-08 01:50:37 +0000576 VideoRendererImpl *This = (VideoRendererImpl *)iface;
Christian Costaf096fa32004-08-24 02:28:35 +0000577
578 TRACE("(%p/%p)->()\n", This, iface);
579
580 EnterCriticalSection(&This->csFilter);
581 {
582 This->state = State_Stopped;
583 }
584 LeaveCriticalSection(&This->csFilter);
585
586 return S_OK;
587}
588
589static HRESULT WINAPI VideoRenderer_Pause(IBaseFilter * iface)
590{
Alexandre Julliardf5f7a182004-09-08 01:50:37 +0000591 VideoRendererImpl *This = (VideoRendererImpl *)iface;
Christian Costaf096fa32004-08-24 02:28:35 +0000592
593 TRACE("(%p/%p)->()\n", This, iface);
594
595 EnterCriticalSection(&This->csFilter);
596 {
597 This->state = State_Paused;
598 }
599 LeaveCriticalSection(&This->csFilter);
600
601 return S_OK;
602}
603
604static HRESULT WINAPI VideoRenderer_Run(IBaseFilter * iface, REFERENCE_TIME tStart)
605{
Alexandre Julliardf5f7a182004-09-08 01:50:37 +0000606 VideoRendererImpl *This = (VideoRendererImpl *)iface;
Christian Costaf096fa32004-08-24 02:28:35 +0000607
608 TRACE("(%p/%p)->(%s)\n", This, iface, wine_dbgstr_longlong(tStart));
609
610 EnterCriticalSection(&This->csFilter);
611 {
612 This->rtStreamStart = tStart;
613 This->state = State_Running;
614 }
615 LeaveCriticalSection(&This->csFilter);
616
617 return S_OK;
618}
619
620static HRESULT WINAPI VideoRenderer_GetState(IBaseFilter * iface, DWORD dwMilliSecsTimeout, FILTER_STATE *pState)
621{
Alexandre Julliardf5f7a182004-09-08 01:50:37 +0000622 VideoRendererImpl *This = (VideoRendererImpl *)iface;
Christian Costaf096fa32004-08-24 02:28:35 +0000623
Hans Leidekkercfbb8592006-10-12 20:57:23 +0200624 TRACE("(%p/%p)->(%d, %p)\n", This, iface, dwMilliSecsTimeout, pState);
Christian Costaf096fa32004-08-24 02:28:35 +0000625
626 EnterCriticalSection(&This->csFilter);
627 {
628 *pState = This->state;
629 }
630 LeaveCriticalSection(&This->csFilter);
631
632 return S_OK;
633}
634
635static HRESULT WINAPI VideoRenderer_SetSyncSource(IBaseFilter * iface, IReferenceClock *pClock)
636{
Alexandre Julliardf5f7a182004-09-08 01:50:37 +0000637 VideoRendererImpl *This = (VideoRendererImpl *)iface;
Christian Costaf096fa32004-08-24 02:28:35 +0000638
639 TRACE("(%p/%p)->(%p)\n", This, iface, pClock);
640
641 EnterCriticalSection(&This->csFilter);
642 {
643 if (This->pClock)
644 IReferenceClock_Release(This->pClock);
645 This->pClock = pClock;
646 if (This->pClock)
647 IReferenceClock_AddRef(This->pClock);
648 }
649 LeaveCriticalSection(&This->csFilter);
650
651 return S_OK;
652}
653
654static HRESULT WINAPI VideoRenderer_GetSyncSource(IBaseFilter * iface, IReferenceClock **ppClock)
655{
Alexandre Julliardf5f7a182004-09-08 01:50:37 +0000656 VideoRendererImpl *This = (VideoRendererImpl *)iface;
Christian Costaf096fa32004-08-24 02:28:35 +0000657
658 TRACE("(%p/%p)->(%p)\n", This, iface, ppClock);
659
660 EnterCriticalSection(&This->csFilter);
661 {
662 *ppClock = This->pClock;
663 IReferenceClock_AddRef(This->pClock);
664 }
665 LeaveCriticalSection(&This->csFilter);
666
667 return S_OK;
668}
669
670/** IBaseFilter implementation **/
671
672static HRESULT WINAPI VideoRenderer_EnumPins(IBaseFilter * iface, IEnumPins **ppEnum)
673{
674 ENUMPINDETAILS epd;
Alexandre Julliardf5f7a182004-09-08 01:50:37 +0000675 VideoRendererImpl *This = (VideoRendererImpl *)iface;
Christian Costaf096fa32004-08-24 02:28:35 +0000676
677 TRACE("(%p/%p)->(%p)\n", This, iface, ppEnum);
678
679 epd.cPins = 1; /* input pin */
680 epd.ppPins = This->ppPins;
681 return IEnumPinsImpl_Construct(&epd, ppEnum);
682}
683
684static HRESULT WINAPI VideoRenderer_FindPin(IBaseFilter * iface, LPCWSTR Id, IPin **ppPin)
685{
Alexandre Julliardf5f7a182004-09-08 01:50:37 +0000686 VideoRendererImpl *This = (VideoRendererImpl *)iface;
Christian Costaf096fa32004-08-24 02:28:35 +0000687
688 TRACE("(%p/%p)->(%p,%p)\n", This, iface, debugstr_w(Id), ppPin);
689
690 FIXME("VideoRenderer::FindPin(...)\n");
691
692 /* FIXME: critical section */
693
694 return E_NOTIMPL;
695}
696
697static HRESULT WINAPI VideoRenderer_QueryFilterInfo(IBaseFilter * iface, FILTER_INFO *pInfo)
698{
Alexandre Julliardf5f7a182004-09-08 01:50:37 +0000699 VideoRendererImpl *This = (VideoRendererImpl *)iface;
Christian Costaf096fa32004-08-24 02:28:35 +0000700
701 TRACE("(%p/%p)->(%p)\n", This, iface, pInfo);
702
703 strcpyW(pInfo->achName, This->filterInfo.achName);
704 pInfo->pGraph = This->filterInfo.pGraph;
705
706 if (pInfo->pGraph)
707 IFilterGraph_AddRef(pInfo->pGraph);
708
709 return S_OK;
710}
711
712static HRESULT WINAPI VideoRenderer_JoinFilterGraph(IBaseFilter * iface, IFilterGraph *pGraph, LPCWSTR pName)
713{
Alexandre Julliardf5f7a182004-09-08 01:50:37 +0000714 VideoRendererImpl *This = (VideoRendererImpl *)iface;
Christian Costaf096fa32004-08-24 02:28:35 +0000715
716 TRACE("(%p/%p)->(%p, %s)\n", This, iface, pGraph, debugstr_w(pName));
717
718 EnterCriticalSection(&This->csFilter);
719 {
720 if (pName)
721 strcpyW(This->filterInfo.achName, pName);
722 else
723 *This->filterInfo.achName = '\0';
724 This->filterInfo.pGraph = pGraph; /* NOTE: do NOT increase ref. count */
725 }
726 LeaveCriticalSection(&This->csFilter);
727
728 return S_OK;
729}
730
731static HRESULT WINAPI VideoRenderer_QueryVendorInfo(IBaseFilter * iface, LPWSTR *pVendorInfo)
732{
Alexandre Julliardf5f7a182004-09-08 01:50:37 +0000733 VideoRendererImpl *This = (VideoRendererImpl *)iface;
Christian Costaf096fa32004-08-24 02:28:35 +0000734 TRACE("(%p/%p)->(%p)\n", This, iface, pVendorInfo);
735 return E_NOTIMPL;
736}
737
738static const IBaseFilterVtbl VideoRenderer_Vtbl =
739{
740 VideoRenderer_QueryInterface,
741 VideoRenderer_AddRef,
742 VideoRenderer_Release,
743 VideoRenderer_GetClassID,
744 VideoRenderer_Stop,
745 VideoRenderer_Pause,
746 VideoRenderer_Run,
747 VideoRenderer_GetState,
748 VideoRenderer_SetSyncSource,
749 VideoRenderer_GetSyncSource,
750 VideoRenderer_EnumPins,
751 VideoRenderer_FindPin,
752 VideoRenderer_QueryFilterInfo,
753 VideoRenderer_JoinFilterGraph,
754 VideoRenderer_QueryVendorInfo
755};
756
Christian Costa7dea79c2005-03-02 10:12:12 +0000757static HRESULT WINAPI VideoRenderer_InputPin_EndOfStream(IPin * iface)
758{
759 InputPin* This = (InputPin*)iface;
760 IMediaEventSink* pEventSink;
761 HRESULT hr;
762
763 TRACE("(%p/%p)->()\n", This, iface);
764
765 hr = IFilterGraph_QueryInterface(((VideoRendererImpl*)This->pin.pinInfo.pFilter)->filterInfo.pGraph, &IID_IMediaEventSink, (LPVOID*)&pEventSink);
766 if (SUCCEEDED(hr))
767 {
768 hr = IMediaEventSink_Notify(pEventSink, EC_COMPLETE, S_OK, 0);
769 IMediaEventSink_Release(pEventSink);
770 }
771
772 return hr;
773}
774
Christian Costaf096fa32004-08-24 02:28:35 +0000775static const IPinVtbl VideoRenderer_InputPin_Vtbl =
776{
777 InputPin_QueryInterface,
778 IPinImpl_AddRef,
779 InputPin_Release,
780 InputPin_Connect,
781 InputPin_ReceiveConnection,
782 IPinImpl_Disconnect,
783 IPinImpl_ConnectedTo,
784 IPinImpl_ConnectionMediaType,
785 IPinImpl_QueryPinInfo,
786 IPinImpl_QueryDirection,
787 IPinImpl_QueryId,
788 IPinImpl_QueryAccept,
789 IPinImpl_EnumMediaTypes,
790 IPinImpl_QueryInternalConnections,
Christian Costa7dea79c2005-03-02 10:12:12 +0000791 VideoRenderer_InputPin_EndOfStream,
Christian Costaf096fa32004-08-24 02:28:35 +0000792 InputPin_BeginFlush,
793 InputPin_EndFlush,
794 InputPin_NewSegment
795};
796
797/*** IUnknown methods ***/
798static HRESULT WINAPI Basicvideo_QueryInterface(IBasicVideo *iface,
799 REFIID riid,
800 LPVOID*ppvObj) {
801 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
802
803 TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_guid(riid), riid, ppvObj);
804
805 return VideoRenderer_QueryInterface((IBaseFilter*)This, riid, ppvObj);
806}
807
808static ULONG WINAPI Basicvideo_AddRef(IBasicVideo *iface) {
809 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
810
811 TRACE("(%p/%p)->()\n", This, iface);
812
813 return VideoRenderer_AddRef((IBaseFilter*)This);
814}
815
816static ULONG WINAPI Basicvideo_Release(IBasicVideo *iface) {
817 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
818
819 TRACE("(%p/%p)->()\n", This, iface);
820
821 return VideoRenderer_Release((IBaseFilter*)This);
822}
823
824/*** IDispatch methods ***/
825static HRESULT WINAPI Basicvideo_GetTypeInfoCount(IBasicVideo *iface,
826 UINT*pctinfo) {
827 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
828
Christian Costaacb2ff22005-06-13 11:37:55 +0000829 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, pctinfo);
Christian Costaf096fa32004-08-24 02:28:35 +0000830
831 return S_OK;
832}
833
834static HRESULT WINAPI Basicvideo_GetTypeInfo(IBasicVideo *iface,
835 UINT iTInfo,
836 LCID lcid,
837 ITypeInfo**ppTInfo) {
838 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
839
Hans Leidekkercfbb8592006-10-12 20:57:23 +0200840 FIXME("(%p/%p)->(%d, %d, %p): stub !!!\n", This, iface, iTInfo, lcid, ppTInfo);
Christian Costaf096fa32004-08-24 02:28:35 +0000841
842 return S_OK;
843}
844
845static HRESULT WINAPI Basicvideo_GetIDsOfNames(IBasicVideo *iface,
846 REFIID riid,
847 LPOLESTR*rgszNames,
848 UINT cNames,
849 LCID lcid,
850 DISPID*rgDispId) {
851 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
852
Hans Leidekkercfbb8592006-10-12 20:57:23 +0200853 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 +0000854
855 return S_OK;
856}
857
858static HRESULT WINAPI Basicvideo_Invoke(IBasicVideo *iface,
859 DISPID dispIdMember,
860 REFIID riid,
861 LCID lcid,
862 WORD wFlags,
863 DISPPARAMS*pDispParams,
864 VARIANT*pVarResult,
865 EXCEPINFO*pExepInfo,
866 UINT*puArgErr) {
867 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
868
Hans Leidekkercfbb8592006-10-12 20:57:23 +0200869 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 +0000870
871 return S_OK;
872}
873
874/*** IBasicVideo methods ***/
875static HRESULT WINAPI Basicvideo_get_AvgTimePerFrame(IBasicVideo *iface,
876 REFTIME *pAvgTimePerFrame) {
877 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
878
Christian Costaacb2ff22005-06-13 11:37:55 +0000879 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, pAvgTimePerFrame);
Christian Costaf096fa32004-08-24 02:28:35 +0000880
881 return S_OK;
882}
883
884static HRESULT WINAPI Basicvideo_get_BitRate(IBasicVideo *iface,
885 long *pBitRate) {
886 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
887
Christian Costaacb2ff22005-06-13 11:37:55 +0000888 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, pBitRate);
Christian Costaf096fa32004-08-24 02:28:35 +0000889
890 return S_OK;
891}
892
893static HRESULT WINAPI Basicvideo_get_BitErrorRate(IBasicVideo *iface,
894 long *pBitErrorRate) {
895 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
896
Christian Costaacb2ff22005-06-13 11:37:55 +0000897 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, pBitErrorRate);
Christian Costaf096fa32004-08-24 02:28:35 +0000898
899 return S_OK;
900}
901
902static HRESULT WINAPI Basicvideo_get_VideoWidth(IBasicVideo *iface,
903 long *pVideoWidth) {
904 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
905
Christian Costaacb2ff22005-06-13 11:37:55 +0000906 TRACE("(%p/%p)->(%p)\n", This, iface, pVideoWidth);
907
908 *pVideoWidth = This->VideoWidth;
Christian Costaf096fa32004-08-24 02:28:35 +0000909
910 return S_OK;
911}
912
913static HRESULT WINAPI Basicvideo_get_VideoHeight(IBasicVideo *iface,
914 long *pVideoHeight) {
915 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
916
Christian Costaacb2ff22005-06-13 11:37:55 +0000917 TRACE("(%p/%p)->(%p)\n", This, iface, pVideoHeight);
918
919 *pVideoHeight = This->VideoHeight;
Christian Costaf096fa32004-08-24 02:28:35 +0000920
921 return S_OK;
922}
923
924static HRESULT WINAPI Basicvideo_put_SourceLeft(IBasicVideo *iface,
925 long SourceLeft) {
926 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
927
Christian Costaacb2ff22005-06-13 11:37:55 +0000928 TRACE("(%p/%p)->(%ld)\n", This, iface, SourceLeft);
929
930 This->SourceRect.left = SourceLeft;
Christian Costaf096fa32004-08-24 02:28:35 +0000931
932 return S_OK;
933}
934
935static HRESULT WINAPI Basicvideo_get_SourceLeft(IBasicVideo *iface,
936 long *pSourceLeft) {
937 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
938
Christian Costaacb2ff22005-06-13 11:37:55 +0000939 TRACE("(%p/%p)->(%p)\n", This, iface, pSourceLeft);
940
941 *pSourceLeft = This->SourceRect.left;
Christian Costaf096fa32004-08-24 02:28:35 +0000942
943 return S_OK;
944}
945
946static HRESULT WINAPI Basicvideo_put_SourceWidth(IBasicVideo *iface,
947 long SourceWidth) {
948 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
949
Christian Costaacb2ff22005-06-13 11:37:55 +0000950 TRACE("(%p/%p)->(%ld)\n", This, iface, SourceWidth);
951
952 This->SourceRect.right = This->SourceRect.left + SourceWidth;
Christian Costaf096fa32004-08-24 02:28:35 +0000953
954 return S_OK;
955}
956
957static HRESULT WINAPI Basicvideo_get_SourceWidth(IBasicVideo *iface,
958 long *pSourceWidth) {
959 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
960
Christian Costaacb2ff22005-06-13 11:37:55 +0000961 TRACE("(%p/%p)->(%p)\n", This, iface, pSourceWidth);
Christian Costaf096fa32004-08-24 02:28:35 +0000962
Christian Costaacb2ff22005-06-13 11:37:55 +0000963 *pSourceWidth = This->SourceRect.right - This->SourceRect.left;
964
Christian Costaf096fa32004-08-24 02:28:35 +0000965 return S_OK;
966}
967
968static HRESULT WINAPI Basicvideo_put_SourceTop(IBasicVideo *iface,
969 long SourceTop) {
970 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
971
Christian Costaacb2ff22005-06-13 11:37:55 +0000972 TRACE("(%p/%p)->(%ld)\n", This, iface, SourceTop);
973
974 This->SourceRect.top = SourceTop;
Christian Costaf096fa32004-08-24 02:28:35 +0000975
976 return S_OK;
977}
978
979static HRESULT WINAPI Basicvideo_get_SourceTop(IBasicVideo *iface,
980 long *pSourceTop) {
981 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
982
Christian Costaacb2ff22005-06-13 11:37:55 +0000983 TRACE("(%p/%p)->(%p)\n", This, iface, pSourceTop);
984
985 *pSourceTop = This->SourceRect.top;
Christian Costaf096fa32004-08-24 02:28:35 +0000986
987 return S_OK;
988}
989
990static HRESULT WINAPI Basicvideo_put_SourceHeight(IBasicVideo *iface,
991 long SourceHeight) {
992 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
993
Christian Costaacb2ff22005-06-13 11:37:55 +0000994 TRACE("(%p/%p)->(%ld)\n", This, iface, SourceHeight);
995
996 This->SourceRect.bottom = This->SourceRect.top + SourceHeight;
Christian Costaf096fa32004-08-24 02:28:35 +0000997
998 return S_OK;
999}
1000
1001static HRESULT WINAPI Basicvideo_get_SourceHeight(IBasicVideo *iface,
1002 long *pSourceHeight) {
1003 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1004
Christian Costaacb2ff22005-06-13 11:37:55 +00001005 TRACE("(%p/%p)->(%p)\n", This, iface, pSourceHeight);
1006
1007 *pSourceHeight = This->SourceRect.bottom - This->SourceRect.top;
Christian Costaf096fa32004-08-24 02:28:35 +00001008
1009 return S_OK;
1010}
1011
1012static HRESULT WINAPI Basicvideo_put_DestinationLeft(IBasicVideo *iface,
1013 long DestinationLeft) {
1014 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1015
Christian Costaacb2ff22005-06-13 11:37:55 +00001016 TRACE("(%p/%p)->(%ld)\n", This, iface, DestinationLeft);
1017
1018 This->DestRect.left = DestinationLeft;
Christian Costaf096fa32004-08-24 02:28:35 +00001019
1020 return S_OK;
1021}
1022
1023static HRESULT WINAPI Basicvideo_get_DestinationLeft(IBasicVideo *iface,
1024 long *pDestinationLeft) {
1025 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1026
Christian Costaacb2ff22005-06-13 11:37:55 +00001027 TRACE("(%p/%p)->(%p)\n", This, iface, pDestinationLeft);
1028
1029 *pDestinationLeft = This->DestRect.left;
Christian Costaf096fa32004-08-24 02:28:35 +00001030
1031 return S_OK;
1032}
1033
1034static HRESULT WINAPI Basicvideo_put_DestinationWidth(IBasicVideo *iface,
1035 long DestinationWidth) {
1036 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1037
Christian Costaacb2ff22005-06-13 11:37:55 +00001038 TRACE("(%p/%p)->(%ld)\n", This, iface, DestinationWidth);
1039
1040 This->DestRect.right = This->DestRect.left + DestinationWidth;
Christian Costaf096fa32004-08-24 02:28:35 +00001041
1042 return S_OK;
1043}
1044
1045static HRESULT WINAPI Basicvideo_get_DestinationWidth(IBasicVideo *iface,
1046 long *pDestinationWidth) {
1047 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1048
Christian Costaacb2ff22005-06-13 11:37:55 +00001049 TRACE("(%p/%p)->(%p)\n", This, iface, pDestinationWidth);
1050
1051 *pDestinationWidth = This->DestRect.right - This->DestRect.left;
Christian Costaf096fa32004-08-24 02:28:35 +00001052
1053 return S_OK;
1054}
1055
1056static HRESULT WINAPI Basicvideo_put_DestinationTop(IBasicVideo *iface,
1057 long DestinationTop) {
1058 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1059
Christian Costaacb2ff22005-06-13 11:37:55 +00001060 TRACE("(%p/%p)->(%ld)\n", This, iface, DestinationTop);
Christian Costaf096fa32004-08-24 02:28:35 +00001061
Christian Costaacb2ff22005-06-13 11:37:55 +00001062 This->DestRect.top = DestinationTop;
1063
Christian Costaf096fa32004-08-24 02:28:35 +00001064 return S_OK;
1065}
1066
1067static HRESULT WINAPI Basicvideo_get_DestinationTop(IBasicVideo *iface,
1068 long *pDestinationTop) {
1069 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1070
Christian Costaacb2ff22005-06-13 11:37:55 +00001071 TRACE("(%p/%p)->(%p)\n", This, iface, pDestinationTop);
1072
1073 *pDestinationTop = This->DestRect.top;
Christian Costaf096fa32004-08-24 02:28:35 +00001074
1075 return S_OK;
1076}
1077
1078static HRESULT WINAPI Basicvideo_put_DestinationHeight(IBasicVideo *iface,
1079 long DestinationHeight) {
1080 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1081
Christian Costaacb2ff22005-06-13 11:37:55 +00001082 TRACE("(%p/%p)->(%ld)\n", This, iface, DestinationHeight);
1083
1084 This->DestRect.right = This->DestRect.left + DestinationHeight;
Christian Costaf096fa32004-08-24 02:28:35 +00001085
1086 return S_OK;
1087}
1088
1089static HRESULT WINAPI Basicvideo_get_DestinationHeight(IBasicVideo *iface,
1090 long *pDestinationHeight) {
1091 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1092
Christian Costaacb2ff22005-06-13 11:37:55 +00001093 TRACE("(%p/%p)->(%p)\n", This, iface, pDestinationHeight);
1094
1095 *pDestinationHeight = This->DestRect.right - This->DestRect.left;
Christian Costaf096fa32004-08-24 02:28:35 +00001096
1097 return S_OK;
1098}
1099
1100static HRESULT WINAPI Basicvideo_SetSourcePosition(IBasicVideo *iface,
1101 long Left,
1102 long Top,
1103 long Width,
1104 long Height) {
1105 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1106
Christian Costaacb2ff22005-06-13 11:37:55 +00001107 TRACE("(%p/%p)->(%ld, %ld, %ld, %ld)\n", This, iface, Left, Top, Width, Height);
Christian Costaf096fa32004-08-24 02:28:35 +00001108
Christian Costaacb2ff22005-06-13 11:37:55 +00001109 This->SourceRect.left = Left;
1110 This->SourceRect.top = Top;
1111 This->SourceRect.right = Left + Width;
1112 This->SourceRect.bottom = Top + Height;
1113
Christian Costaf096fa32004-08-24 02:28:35 +00001114 return S_OK;
1115}
1116
1117static HRESULT WINAPI Basicvideo_GetSourcePosition(IBasicVideo *iface,
1118 long *pLeft,
1119 long *pTop,
1120 long *pWidth,
1121 long *pHeight) {
1122 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1123
Christian Costaacb2ff22005-06-13 11:37:55 +00001124 TRACE("(%p/%p)->(%p, %p, %p, %p)\n", This, iface, pLeft, pTop, pWidth, pHeight);
Christian Costaf096fa32004-08-24 02:28:35 +00001125
Christian Costaacb2ff22005-06-13 11:37:55 +00001126 *pLeft = This->SourceRect.left;
1127 *pTop = This->SourceRect.top;
1128 *pWidth = This->SourceRect.right - This->SourceRect.left;
1129 *pHeight = This->SourceRect.bottom - This->SourceRect.top;
1130
Christian Costaf096fa32004-08-24 02:28:35 +00001131 return S_OK;
1132}
1133
1134static HRESULT WINAPI Basicvideo_SetDefaultSourcePosition(IBasicVideo *iface) {
1135 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1136
Christian Costaacb2ff22005-06-13 11:37:55 +00001137 TRACE("(%p/%p)->()\n", This, iface);
1138
1139 This->SourceRect.left = 0;
1140 This->SourceRect.top = 0;
1141 This->SourceRect.right = This->VideoWidth;
1142 This->SourceRect.bottom = This->VideoHeight;
Christian Costaf096fa32004-08-24 02:28:35 +00001143
1144 return S_OK;
1145}
1146
1147static HRESULT WINAPI Basicvideo_SetDestinationPosition(IBasicVideo *iface,
1148 long Left,
1149 long Top,
1150 long Width,
1151 long Height) {
1152 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1153
Christian Costaacb2ff22005-06-13 11:37:55 +00001154 TRACE("(%p/%p)->(%ld, %ld, %ld, %ld)\n", This, iface, Left, Top, Width, Height);
1155
1156 This->DestRect.left = Left;
1157 This->DestRect.top = Top;
1158 This->DestRect.right = Left + Width;
1159 This->DestRect.bottom = Top + Height;
Christian Costaf096fa32004-08-24 02:28:35 +00001160
1161 return S_OK;
1162}
1163
1164static HRESULT WINAPI Basicvideo_GetDestinationPosition(IBasicVideo *iface,
1165 long *pLeft,
1166 long *pTop,
1167 long *pWidth,
1168 long *pHeight) {
1169 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1170
Christian Costaacb2ff22005-06-13 11:37:55 +00001171 TRACE("(%p/%p)->(%p, %p, %p, %p)\n", This, iface, pLeft, pTop, pWidth, pHeight);
1172
1173 *pLeft = This->DestRect.left;
1174 *pTop = This->DestRect.top;
1175 *pWidth = This->DestRect.right - This->DestRect.left;
1176 *pHeight = This->DestRect.bottom - This->DestRect.top;
Christian Costaf096fa32004-08-24 02:28:35 +00001177
1178 return S_OK;
1179}
1180
1181static HRESULT WINAPI Basicvideo_SetDefaultDestinationPosition(IBasicVideo *iface) {
1182 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
Christian Costaacb2ff22005-06-13 11:37:55 +00001183 RECT rect;
Christian Costaf096fa32004-08-24 02:28:35 +00001184
Christian Costaacb2ff22005-06-13 11:37:55 +00001185 TRACE("(%p/%p)->()\n", This, iface);
Christian Costaf096fa32004-08-24 02:28:35 +00001186
Christian Costaacb2ff22005-06-13 11:37:55 +00001187 if (!GetClientRect(This->hWnd, &rect))
1188 return E_FAIL;
1189
1190 This->SourceRect.left = 0;
1191 This->SourceRect.top = 0;
1192 This->SourceRect.right = rect.right;
1193 This->SourceRect.bottom = rect.bottom;
1194
Christian Costaf096fa32004-08-24 02:28:35 +00001195 return S_OK;
1196}
1197
1198static HRESULT WINAPI Basicvideo_GetVideoSize(IBasicVideo *iface,
1199 long *pWidth,
1200 long *pHeight) {
1201 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1202
Christian Costaacb2ff22005-06-13 11:37:55 +00001203 TRACE("(%p/%p)->(%p, %p)\n", This, iface, pWidth, pHeight);
Christian Costaf096fa32004-08-24 02:28:35 +00001204
Christian Costaacb2ff22005-06-13 11:37:55 +00001205 *pWidth = This->VideoWidth;
1206 *pHeight = This->VideoHeight;
1207
Christian Costaf096fa32004-08-24 02:28:35 +00001208 return S_OK;
1209}
1210
1211static HRESULT WINAPI Basicvideo_GetVideoPaletteEntries(IBasicVideo *iface,
1212 long StartIndex,
1213 long Entries,
1214 long *pRetrieved,
1215 long *pPalette) {
1216 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1217
Christian Costaacb2ff22005-06-13 11:37:55 +00001218 FIXME("(%p/%p)->(%ld, %ld, %p, %p): stub !!!\n", This, iface, StartIndex, Entries, pRetrieved, pPalette);
Christian Costaf096fa32004-08-24 02:28:35 +00001219
1220 return S_OK;
1221}
1222
1223static HRESULT WINAPI Basicvideo_GetCurrentImage(IBasicVideo *iface,
1224 long *pBufferSize,
1225 long *pDIBImage) {
1226 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1227
Christian Costaacb2ff22005-06-13 11:37:55 +00001228 FIXME("(%p/%p)->(%p, %p): stub !!!\n", This, iface, pBufferSize, pDIBImage);
Christian Costaf096fa32004-08-24 02:28:35 +00001229
1230 return S_OK;
1231}
1232
1233static HRESULT WINAPI Basicvideo_IsUsingDefaultSource(IBasicVideo *iface) {
1234 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1235
Christian Costaacb2ff22005-06-13 11:37:55 +00001236 FIXME("(%p/%p)->(): stub !!!\n", This, iface);
Christian Costaf096fa32004-08-24 02:28:35 +00001237
1238 return S_OK;
1239}
1240
1241static HRESULT WINAPI Basicvideo_IsUsingDefaultDestination(IBasicVideo *iface) {
1242 ICOM_THIS_MULTI(VideoRendererImpl, IBasicVideo_vtbl, iface);
1243
Christian Costaacb2ff22005-06-13 11:37:55 +00001244 FIXME("(%p/%p)->(): stub !!!\n", This, iface);
Christian Costaf096fa32004-08-24 02:28:35 +00001245
1246 return S_OK;
1247}
1248
1249
Dmitry Timoshkoveba47f12005-06-06 19:50:35 +00001250static const IBasicVideoVtbl IBasicVideo_VTable =
Christian Costaf096fa32004-08-24 02:28:35 +00001251{
1252 Basicvideo_QueryInterface,
1253 Basicvideo_AddRef,
1254 Basicvideo_Release,
1255 Basicvideo_GetTypeInfoCount,
1256 Basicvideo_GetTypeInfo,
1257 Basicvideo_GetIDsOfNames,
1258 Basicvideo_Invoke,
1259 Basicvideo_get_AvgTimePerFrame,
1260 Basicvideo_get_BitRate,
1261 Basicvideo_get_BitErrorRate,
1262 Basicvideo_get_VideoWidth,
1263 Basicvideo_get_VideoHeight,
1264 Basicvideo_put_SourceLeft,
1265 Basicvideo_get_SourceLeft,
1266 Basicvideo_put_SourceWidth,
1267 Basicvideo_get_SourceWidth,
1268 Basicvideo_put_SourceTop,
1269 Basicvideo_get_SourceTop,
1270 Basicvideo_put_SourceHeight,
1271 Basicvideo_get_SourceHeight,
1272 Basicvideo_put_DestinationLeft,
1273 Basicvideo_get_DestinationLeft,
1274 Basicvideo_put_DestinationWidth,
1275 Basicvideo_get_DestinationWidth,
1276 Basicvideo_put_DestinationTop,
1277 Basicvideo_get_DestinationTop,
1278 Basicvideo_put_DestinationHeight,
1279 Basicvideo_get_DestinationHeight,
1280 Basicvideo_SetSourcePosition,
1281 Basicvideo_GetSourcePosition,
1282 Basicvideo_SetDefaultSourcePosition,
1283 Basicvideo_SetDestinationPosition,
1284 Basicvideo_GetDestinationPosition,
1285 Basicvideo_SetDefaultDestinationPosition,
1286 Basicvideo_GetVideoSize,
1287 Basicvideo_GetVideoPaletteEntries,
1288 Basicvideo_GetCurrentImage,
1289 Basicvideo_IsUsingDefaultSource,
1290 Basicvideo_IsUsingDefaultDestination
1291};
1292
1293
1294/*** IUnknown methods ***/
1295static HRESULT WINAPI Videowindow_QueryInterface(IVideoWindow *iface,
1296 REFIID riid,
1297 LPVOID*ppvObj) {
1298 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1299
1300 TRACE("(%p/%p)->(%s (%p), %p)\n", This, iface, debugstr_guid(riid), riid, ppvObj);
1301
1302 return VideoRenderer_QueryInterface((IBaseFilter*)This, riid, ppvObj);
1303}
1304
1305static ULONG WINAPI Videowindow_AddRef(IVideoWindow *iface) {
1306 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1307
1308 TRACE("(%p/%p)->()\n", This, iface);
1309
1310 return VideoRenderer_AddRef((IBaseFilter*)This);
1311}
1312
1313static ULONG WINAPI Videowindow_Release(IVideoWindow *iface) {
1314 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1315
1316 TRACE("(%p/%p)->()\n", This, iface);
1317
1318 return VideoRenderer_Release((IBaseFilter*)This);
1319}
1320
1321/*** IDispatch methods ***/
1322static HRESULT WINAPI Videowindow_GetTypeInfoCount(IVideoWindow *iface,
1323 UINT*pctinfo) {
1324 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1325
Christian Costaacb2ff22005-06-13 11:37:55 +00001326 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, pctinfo);
Christian Costaf096fa32004-08-24 02:28:35 +00001327
1328 return S_OK;
1329}
1330
1331static HRESULT WINAPI Videowindow_GetTypeInfo(IVideoWindow *iface,
1332 UINT iTInfo,
1333 LCID lcid,
1334 ITypeInfo**ppTInfo) {
1335 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1336
Hans Leidekkercfbb8592006-10-12 20:57:23 +02001337 FIXME("(%p/%p)->(%d, %d, %p): stub !!!\n", This, iface, iTInfo, lcid, ppTInfo);
Christian Costaf096fa32004-08-24 02:28:35 +00001338
1339 return S_OK;
1340}
1341
1342static HRESULT WINAPI Videowindow_GetIDsOfNames(IVideoWindow *iface,
1343 REFIID riid,
1344 LPOLESTR*rgszNames,
1345 UINT cNames,
1346 LCID lcid,
1347 DISPID*rgDispId) {
1348 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1349
Hans Leidekkercfbb8592006-10-12 20:57:23 +02001350 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 +00001351
1352 return S_OK;
1353}
1354
1355static HRESULT WINAPI Videowindow_Invoke(IVideoWindow *iface,
1356 DISPID dispIdMember,
1357 REFIID riid,
1358 LCID lcid,
1359 WORD wFlags,
1360 DISPPARAMS*pDispParams,
1361 VARIANT*pVarResult,
1362 EXCEPINFO*pExepInfo,
1363 UINT*puArgErr) {
1364 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1365
Hans Leidekkercfbb8592006-10-12 20:57:23 +02001366 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 +00001367
1368 return S_OK;
1369}
1370
1371/*** IVideoWindow methods ***/
1372static HRESULT WINAPI Videowindow_put_Caption(IVideoWindow *iface,
1373 BSTR strCaption) {
1374 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1375
Christian Costaacb2ff22005-06-13 11:37:55 +00001376 TRACE("(%p/%p)->(%s (%p))\n", This, iface, debugstr_w(strCaption), strCaption);
1377
1378 if (!SetWindowTextW(This->hWnd, strCaption))
1379 return E_FAIL;
Christian Costaf096fa32004-08-24 02:28:35 +00001380
1381 return S_OK;
1382}
1383
1384static HRESULT WINAPI Videowindow_get_Caption(IVideoWindow *iface,
1385 BSTR *strCaption) {
1386 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1387
Christian Costaacb2ff22005-06-13 11:37:55 +00001388 TRACE("(%p/%p)->(%p)\n", This, iface, strCaption);
1389
1390 GetWindowTextW(This->hWnd, (LPWSTR)strCaption, 100);
Christian Costaf096fa32004-08-24 02:28:35 +00001391
1392 return S_OK;
1393}
1394
1395static HRESULT WINAPI Videowindow_put_WindowStyle(IVideoWindow *iface,
1396 long WindowStyle) {
1397 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
Christian Costaacb2ff22005-06-13 11:37:55 +00001398 LONG old;
Christian Costaf096fa32004-08-24 02:28:35 +00001399
Christian Costaacb2ff22005-06-13 11:37:55 +00001400 old = GetWindowLongA(This->hWnd, GWL_STYLE);
1401
Hans Leidekkercfbb8592006-10-12 20:57:23 +02001402 TRACE("(%p/%p)->(%x -> %lx)\n", This, iface, old, WindowStyle);
Christian Costaacb2ff22005-06-13 11:37:55 +00001403
1404 if (WindowStyle & (WS_DISABLED|WS_HSCROLL|WS_ICONIC|WS_MAXIMIZE|WS_MINIMIZE|WS_VSCROLL))
1405 return E_INVALIDARG;
1406
1407 SetWindowLongA(This->hWnd, GWL_STYLE, WindowStyle);
Christian Costaf096fa32004-08-24 02:28:35 +00001408
1409 return S_OK;
1410}
1411
1412static HRESULT WINAPI Videowindow_get_WindowStyle(IVideoWindow *iface,
1413 long *WindowStyle) {
1414 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1415
Christian Costaacb2ff22005-06-13 11:37:55 +00001416 TRACE("(%p/%p)->(%p)\n", This, iface, WindowStyle);
1417
1418 *WindowStyle = GetWindowLongA(This->hWnd, GWL_STYLE);
Christian Costaf096fa32004-08-24 02:28:35 +00001419
1420 return S_OK;
1421}
1422
1423static HRESULT WINAPI Videowindow_put_WindowStyleEx(IVideoWindow *iface,
1424 long WindowStyleEx) {
1425 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1426
Christian Costaacb2ff22005-06-13 11:37:55 +00001427 TRACE("(%p/%p)->(%ld)\n", This, iface, WindowStyleEx);
1428
1429 if (WindowStyleEx & (WS_DISABLED|WS_HSCROLL|WS_ICONIC|WS_MAXIMIZE|WS_MINIMIZE|WS_VSCROLL))
1430 return E_INVALIDARG;
1431
1432 if (!SetWindowLongA(This->hWnd, GWL_EXSTYLE, WindowStyleEx))
1433 return E_FAIL;
Christian Costaf096fa32004-08-24 02:28:35 +00001434
1435 return S_OK;
1436}
1437
1438static HRESULT WINAPI Videowindow_get_WindowStyleEx(IVideoWindow *iface,
1439 long *WindowStyleEx) {
1440 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1441
Christian Costaacb2ff22005-06-13 11:37:55 +00001442 TRACE("(%p/%p)->(%p)\n", This, iface, WindowStyleEx);
1443
1444 *WindowStyleEx = GetWindowLongA(This->hWnd, GWL_EXSTYLE);
Christian Costaf096fa32004-08-24 02:28:35 +00001445
1446 return S_OK;
1447}
1448
1449static HRESULT WINAPI Videowindow_put_AutoShow(IVideoWindow *iface,
1450 long AutoShow) {
1451 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1452
Christian Costaacb2ff22005-06-13 11:37:55 +00001453 TRACE("(%p/%p)->(%ld)\n", This, iface, AutoShow);
1454
1455 This->AutoShow = 1; /* FXIME: Should be AutoShow */;
Christian Costaf096fa32004-08-24 02:28:35 +00001456
1457 return S_OK;
1458}
1459
1460static HRESULT WINAPI Videowindow_get_AutoShow(IVideoWindow *iface,
1461 long *AutoShow) {
1462 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1463
Christian Costaacb2ff22005-06-13 11:37:55 +00001464 TRACE("(%p/%p)->(%p)\n", This, iface, AutoShow);
1465
1466 *AutoShow = This->AutoShow;
Christian Costaf096fa32004-08-24 02:28:35 +00001467
1468 return S_OK;
1469}
1470
1471static HRESULT WINAPI Videowindow_put_WindowState(IVideoWindow *iface,
1472 long WindowState) {
1473 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1474
Christian Costaacb2ff22005-06-13 11:37:55 +00001475 FIXME("(%p/%p)->(%ld): stub !!!\n", This, iface, WindowState);
Christian Costaf096fa32004-08-24 02:28:35 +00001476
1477 return S_OK;
1478}
1479
1480static HRESULT WINAPI Videowindow_get_WindowState(IVideoWindow *iface,
1481 long *WindowState) {
1482 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1483
Christian Costaacb2ff22005-06-13 11:37:55 +00001484 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, WindowState);
Christian Costaf096fa32004-08-24 02:28:35 +00001485
1486 return S_OK;
1487}
1488
1489static HRESULT WINAPI Videowindow_put_BackgroundPalette(IVideoWindow *iface,
1490 long BackgroundPalette) {
1491 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1492
Christian Costaacb2ff22005-06-13 11:37:55 +00001493 FIXME("(%p/%p)->(%ld): stub !!!\n", This, iface, BackgroundPalette);
Christian Costaf096fa32004-08-24 02:28:35 +00001494
1495 return S_OK;
1496}
1497
1498static HRESULT WINAPI Videowindow_get_BackgroundPalette(IVideoWindow *iface,
1499 long *pBackgroundPalette) {
1500 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1501
Christian Costaacb2ff22005-06-13 11:37:55 +00001502 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, pBackgroundPalette);
Christian Costaf096fa32004-08-24 02:28:35 +00001503
1504 return S_OK;
1505}
1506
1507static HRESULT WINAPI Videowindow_put_Visible(IVideoWindow *iface,
1508 long Visible) {
1509 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1510
Christian Costaacb2ff22005-06-13 11:37:55 +00001511 TRACE("(%p/%p)->(%ld)\n", This, iface, Visible);
1512
1513 ShowWindow(This->hWnd, Visible ? SW_SHOW : SW_HIDE);
Christian Costaf096fa32004-08-24 02:28:35 +00001514
1515 return S_OK;
1516}
1517
1518static HRESULT WINAPI Videowindow_get_Visible(IVideoWindow *iface,
1519 long *pVisible) {
1520 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1521
Christian Costaacb2ff22005-06-13 11:37:55 +00001522 TRACE("(%p/%p)->(%p)\n", This, iface, pVisible);
1523
1524 *pVisible = IsWindowVisible(This->hWnd);
Christian Costaf096fa32004-08-24 02:28:35 +00001525
1526 return S_OK;
1527}
1528
1529static HRESULT WINAPI Videowindow_put_Left(IVideoWindow *iface,
1530 long Left) {
1531 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1532
Christian Costaacb2ff22005-06-13 11:37:55 +00001533 TRACE("(%p/%p)->(%ld)\n", This, iface, Left);
1534
1535 if (!SetWindowPos(This->hWnd, NULL, Left, This->WindowPos.top, 0, 0, SWP_NOZORDER|SWP_NOSIZE))
1536 return E_FAIL;
1537
1538 This->WindowPos.left = Left;
Christian Costaf096fa32004-08-24 02:28:35 +00001539
1540 return S_OK;
1541}
1542
1543static HRESULT WINAPI Videowindow_get_Left(IVideoWindow *iface,
1544 long *pLeft) {
1545 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1546
Christian Costaacb2ff22005-06-13 11:37:55 +00001547 TRACE("(%p/%p)->(%p)\n", This, iface, pLeft);
1548
1549 *pLeft = This->WindowPos.left;
Christian Costaf096fa32004-08-24 02:28:35 +00001550
1551 return S_OK;
1552}
1553
1554static HRESULT WINAPI Videowindow_put_Width(IVideoWindow *iface,
1555 long Width) {
1556 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1557
Christian Costaacb2ff22005-06-13 11:37:55 +00001558 TRACE("(%p/%p)->(%ld)\n", This, iface, Width);
1559
1560 if (!SetWindowPos(This->hWnd, NULL, 0, 0, Width, This->WindowPos.bottom-This->WindowPos.top, SWP_NOZORDER|SWP_NOMOVE))
1561 return E_FAIL;
1562
1563 This->WindowPos.right = This->WindowPos.left + Width;
Christian Costaf096fa32004-08-24 02:28:35 +00001564
1565 return S_OK;
1566}
1567
1568static HRESULT WINAPI Videowindow_get_Width(IVideoWindow *iface,
1569 long *pWidth) {
1570 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1571
Christian Costaacb2ff22005-06-13 11:37:55 +00001572 TRACE("(%p/%p)->(%p)\n", This, iface, pWidth);
1573
1574 *pWidth = This->WindowPos.right - This->WindowPos.left;
Christian Costaf096fa32004-08-24 02:28:35 +00001575
1576 return S_OK;
1577}
1578
1579static HRESULT WINAPI Videowindow_put_Top(IVideoWindow *iface,
1580 long Top) {
1581 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1582
Christian Costaacb2ff22005-06-13 11:37:55 +00001583 TRACE("(%p/%p)->(%ld)\n", This, iface, Top);
1584
1585 if (!SetWindowPos(This->hWnd, NULL, This->WindowPos.left, Top, 0, 0, SWP_NOZORDER|SWP_NOSIZE))
1586 return E_FAIL;
1587
1588 This->WindowPos.top = Top;
Christian Costaf096fa32004-08-24 02:28:35 +00001589
1590 return S_OK;
1591}
1592
1593static HRESULT WINAPI Videowindow_get_Top(IVideoWindow *iface,
1594 long *pTop) {
1595 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1596
Christian Costaacb2ff22005-06-13 11:37:55 +00001597 TRACE("(%p/%p)->(%p)\n", This, iface, pTop);
1598
1599 *pTop = This->WindowPos.top;
Christian Costaf096fa32004-08-24 02:28:35 +00001600
1601 return S_OK;
1602}
1603
1604static HRESULT WINAPI Videowindow_put_Height(IVideoWindow *iface,
1605 long Height) {
1606 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1607
Christian Costaacb2ff22005-06-13 11:37:55 +00001608 TRACE("(%p/%p)->(%ld)\n", This, iface, Height);
1609
1610 if (!SetWindowPos(This->hWnd, NULL, 0, 0, This->WindowPos.right-This->WindowPos.left, Height, SWP_NOZORDER|SWP_NOMOVE))
1611 return E_FAIL;
1612
1613 This->WindowPos.bottom = This->WindowPos.top + Height;
Christian Costaf096fa32004-08-24 02:28:35 +00001614
1615 return S_OK;
1616}
1617
1618static HRESULT WINAPI Videowindow_get_Height(IVideoWindow *iface,
1619 long *pHeight) {
1620 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1621
Christian Costaacb2ff22005-06-13 11:37:55 +00001622 TRACE("(%p/%p)->(%p)\n", This, iface, pHeight);
1623
1624 *pHeight = This->WindowPos.bottom - This->WindowPos.top;
Christian Costaf096fa32004-08-24 02:28:35 +00001625
1626 return S_OK;
1627}
1628
1629static HRESULT WINAPI Videowindow_put_Owner(IVideoWindow *iface,
1630 OAHWND Owner) {
1631 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1632
Hans Leidekkercfbb8592006-10-12 20:57:23 +02001633 TRACE("(%p/%p)->(%08x)\n", This, iface, (DWORD) Owner);
Christian Costaacb2ff22005-06-13 11:37:55 +00001634
1635 SetParent(This->hWnd, (HWND)Owner);
Christian Costaf096fa32004-08-24 02:28:35 +00001636
1637 return S_OK;
1638}
1639
1640static HRESULT WINAPI Videowindow_get_Owner(IVideoWindow *iface,
1641 OAHWND *Owner) {
1642 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1643
Hans Leidekkercfbb8592006-10-12 20:57:23 +02001644 TRACE("(%p/%p)->(%08x)\n", This, iface, (DWORD) Owner);
Christian Costaacb2ff22005-06-13 11:37:55 +00001645
1646 *(HWND*)Owner = GetParent(This->hWnd);
Christian Costaf096fa32004-08-24 02:28:35 +00001647
1648 return S_OK;
1649}
1650
1651static HRESULT WINAPI Videowindow_put_MessageDrain(IVideoWindow *iface,
1652 OAHWND Drain) {
1653 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1654
Hans Leidekkercfbb8592006-10-12 20:57:23 +02001655 TRACE("(%p/%p)->(%08x)\n", This, iface, (DWORD) Drain);
Christian Costaacb2ff22005-06-13 11:37:55 +00001656
1657 This->hWndMsgDrain = (HWND)Drain;
Christian Costaf096fa32004-08-24 02:28:35 +00001658
1659 return S_OK;
1660}
1661
1662static HRESULT WINAPI Videowindow_get_MessageDrain(IVideoWindow *iface,
1663 OAHWND *Drain) {
1664 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1665
Christian Costaacb2ff22005-06-13 11:37:55 +00001666 TRACE("(%p/%p)->(%p)\n", This, iface, Drain);
1667
1668 *Drain = (OAHWND)This->hWndMsgDrain;
Christian Costaf096fa32004-08-24 02:28:35 +00001669
1670 return S_OK;
1671}
1672
1673static HRESULT WINAPI Videowindow_get_BorderColor(IVideoWindow *iface,
1674 long *Color) {
1675 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1676
Christian Costaacb2ff22005-06-13 11:37:55 +00001677 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, Color);
Christian Costaf096fa32004-08-24 02:28:35 +00001678
1679 return S_OK;
1680}
1681
1682static HRESULT WINAPI Videowindow_put_BorderColor(IVideoWindow *iface,
1683 long Color) {
1684 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1685
Christian Costaacb2ff22005-06-13 11:37:55 +00001686 FIXME("(%p/%p)->(%ld): stub !!!\n", This, iface, Color);
Christian Costaf096fa32004-08-24 02:28:35 +00001687
1688 return S_OK;
1689}
1690
1691static HRESULT WINAPI Videowindow_get_FullScreenMode(IVideoWindow *iface,
1692 long *FullScreenMode) {
1693 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1694
Christian Costaacb2ff22005-06-13 11:37:55 +00001695 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, FullScreenMode);
Christian Costaf096fa32004-08-24 02:28:35 +00001696
1697 return S_OK;
1698}
1699
1700static HRESULT WINAPI Videowindow_put_FullScreenMode(IVideoWindow *iface,
1701 long FullScreenMode) {
1702 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1703
Christian Costaacb2ff22005-06-13 11:37:55 +00001704 FIXME("(%p/%p)->(%ld): stub !!!\n", This, iface, FullScreenMode);
Christian Costaf096fa32004-08-24 02:28:35 +00001705
1706 return S_OK;
1707}
1708
1709static HRESULT WINAPI Videowindow_SetWindowForeground(IVideoWindow *iface,
1710 long Focus) {
1711 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
Christian Costaacb2ff22005-06-13 11:37:55 +00001712 BOOL ret;
1713 IPin* pPin;
1714 HRESULT hr;
Christian Costaf096fa32004-08-24 02:28:35 +00001715
Christian Costaacb2ff22005-06-13 11:37:55 +00001716 TRACE("(%p/%p)->(%ld)\n", This, iface, Focus);
1717
1718 if ((Focus != FALSE) && (Focus != TRUE))
1719 return E_INVALIDARG;
1720
1721 hr = IPin_ConnectedTo(This->ppPins[0], &pPin);
1722 if ((hr != S_OK) || !pPin)
1723 return VFW_E_NOT_CONNECTED;
1724
1725 if (Focus)
1726 ret = SetForegroundWindow(This->hWnd);
1727 else
1728 ret = SetWindowPos(This->hWnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
1729
1730 if (!ret)
1731 return E_FAIL;
Christian Costaf096fa32004-08-24 02:28:35 +00001732
1733 return S_OK;
1734}
1735
1736static HRESULT WINAPI Videowindow_NotifyOwnerMessage(IVideoWindow *iface,
1737 OAHWND hwnd,
1738 long uMsg,
1739 LONG_PTR wParam,
1740 LONG_PTR lParam) {
1741 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1742
Hans Leidekkercfbb8592006-10-12 20:57:23 +02001743 TRACE("(%p/%p)->(%08x, %ld, %08lx, %08lx)\n", This, iface, (DWORD) hwnd, uMsg, wParam, lParam);
Christian Costaf096fa32004-08-24 02:28:35 +00001744
Christian Costaacb2ff22005-06-13 11:37:55 +00001745 if (!PostMessageA(This->hWnd, uMsg, wParam, lParam))
1746 return E_FAIL;
1747
Christian Costaf096fa32004-08-24 02:28:35 +00001748 return S_OK;
1749}
1750
1751static HRESULT WINAPI Videowindow_SetWindowPosition(IVideoWindow *iface,
1752 long Left,
1753 long Top,
1754 long Width,
1755 long Height) {
1756 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1757
Christian Costaacb2ff22005-06-13 11:37:55 +00001758 TRACE("(%p/%p)->(%ld, %ld, %ld, %ld)\n", This, iface, Left, Top, Width, Height);
Christian Costaf096fa32004-08-24 02:28:35 +00001759
Christian Costaacb2ff22005-06-13 11:37:55 +00001760 if (!SetWindowPos(This->hWnd, NULL, Left, Top, Width, Height, SWP_NOZORDER))
1761 return E_FAIL;
1762
1763 This->WindowPos.left = Left;
1764 This->WindowPos.top = Top;
1765 This->WindowPos.right = Left + Width;
1766 This->WindowPos.bottom = Top + Height;
1767
Christian Costaf096fa32004-08-24 02:28:35 +00001768 return S_OK;
1769}
1770
1771static HRESULT WINAPI Videowindow_GetWindowPosition(IVideoWindow *iface,
1772 long *pLeft,
1773 long *pTop,
1774 long *pWidth,
1775 long *pHeight) {
1776 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1777
Christian Costaacb2ff22005-06-13 11:37:55 +00001778 TRACE("(%p/%p)->(%p, %p, %p, %p)\n", This, iface, pLeft, pTop, pWidth, pHeight);
1779
1780 *pLeft = This->WindowPos.left;
1781 *pTop = This->WindowPos.top;
1782 *pWidth = This->WindowPos.right - This->WindowPos.left;
1783 *pHeight = This->WindowPos.bottom - This->WindowPos.top;
Christian Costaf096fa32004-08-24 02:28:35 +00001784
1785 return S_OK;
1786}
1787
1788static HRESULT WINAPI Videowindow_GetMinIdealImageSize(IVideoWindow *iface,
1789 long *pWidth,
1790 long *pHeight) {
1791 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1792
Christian Costaacb2ff22005-06-13 11:37:55 +00001793 FIXME("(%p/%p)->(%p, %p): semi stub !!!\n", This, iface, pWidth, pHeight);
1794
1795 *pWidth = This->VideoWidth;
1796 *pHeight = This->VideoHeight;
Christian Costaf096fa32004-08-24 02:28:35 +00001797
1798 return S_OK;
1799}
1800
1801static HRESULT WINAPI Videowindow_GetMaxIdealImageSize(IVideoWindow *iface,
1802 long *pWidth,
1803 long *pHeight) {
1804 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1805
Christian Costaacb2ff22005-06-13 11:37:55 +00001806 FIXME("(%p/%p)->(%p, %p): semi stub !!!\n", This, iface, pWidth, pHeight);
1807
1808 *pWidth = This->VideoWidth;
1809 *pHeight = This->VideoHeight;
Christian Costaf096fa32004-08-24 02:28:35 +00001810
1811 return S_OK;
1812}
1813
1814static HRESULT WINAPI Videowindow_GetRestorePosition(IVideoWindow *iface,
1815 long *pLeft,
1816 long *pTop,
1817 long *pWidth,
1818 long *pHeight) {
1819 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1820
Christian Costaacb2ff22005-06-13 11:37:55 +00001821 FIXME("(%p/%p)->(%p, %p, %p, %p): stub !!!\n", This, iface, pLeft, pTop, pWidth, pHeight);
Christian Costaf096fa32004-08-24 02:28:35 +00001822
1823 return S_OK;
1824}
1825
1826static HRESULT WINAPI Videowindow_HideCursor(IVideoWindow *iface,
1827 long HideCursor) {
1828 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1829
Christian Costaacb2ff22005-06-13 11:37:55 +00001830 FIXME("(%p/%p)->(%ld): stub !!!\n", This, iface, HideCursor);
Christian Costaf096fa32004-08-24 02:28:35 +00001831
1832 return S_OK;
1833}
1834
1835static HRESULT WINAPI Videowindow_IsCursorHidden(IVideoWindow *iface,
1836 long *CursorHidden) {
1837 ICOM_THIS_MULTI(VideoRendererImpl, IVideoWindow_vtbl, iface);
1838
Christian Costaacb2ff22005-06-13 11:37:55 +00001839 FIXME("(%p/%p)->(%p): stub !!!\n", This, iface, CursorHidden);
Christian Costaf096fa32004-08-24 02:28:35 +00001840
1841 return S_OK;
1842}
1843
Dmitry Timoshkoveba47f12005-06-06 19:50:35 +00001844static const IVideoWindowVtbl IVideoWindow_VTable =
Christian Costaf096fa32004-08-24 02:28:35 +00001845{
1846 Videowindow_QueryInterface,
1847 Videowindow_AddRef,
1848 Videowindow_Release,
1849 Videowindow_GetTypeInfoCount,
1850 Videowindow_GetTypeInfo,
1851 Videowindow_GetIDsOfNames,
1852 Videowindow_Invoke,
1853 Videowindow_put_Caption,
1854 Videowindow_get_Caption,
1855 Videowindow_put_WindowStyle,
1856 Videowindow_get_WindowStyle,
1857 Videowindow_put_WindowStyleEx,
1858 Videowindow_get_WindowStyleEx,
1859 Videowindow_put_AutoShow,
1860 Videowindow_get_AutoShow,
1861 Videowindow_put_WindowState,
1862 Videowindow_get_WindowState,
1863 Videowindow_put_BackgroundPalette,
1864 Videowindow_get_BackgroundPalette,
1865 Videowindow_put_Visible,
1866 Videowindow_get_Visible,
1867 Videowindow_put_Left,
1868 Videowindow_get_Left,
1869 Videowindow_put_Width,
1870 Videowindow_get_Width,
1871 Videowindow_put_Top,
1872 Videowindow_get_Top,
1873 Videowindow_put_Height,
1874 Videowindow_get_Height,
1875 Videowindow_put_Owner,
1876 Videowindow_get_Owner,
1877 Videowindow_put_MessageDrain,
1878 Videowindow_get_MessageDrain,
1879 Videowindow_get_BorderColor,
1880 Videowindow_put_BorderColor,
1881 Videowindow_get_FullScreenMode,
1882 Videowindow_put_FullScreenMode,
1883 Videowindow_SetWindowForeground,
1884 Videowindow_NotifyOwnerMessage,
1885 Videowindow_SetWindowPosition,
1886 Videowindow_GetWindowPosition,
1887 Videowindow_GetMinIdealImageSize,
1888 Videowindow_GetMaxIdealImageSize,
1889 Videowindow_GetRestorePosition,
1890 Videowindow_HideCursor,
1891 Videowindow_IsCursorHidden
1892};