/*************************************************************************** * MCIQTZ_mciPlay [internal] */ static DWORD MCIQTZ_mciPlay(UINT wDevID, DWORD dwFlags, LPMCI_PLAY_PARMS lpParms) { WINE_MCIQTZ* wma; HRESULT hr; TRACE("(%04x, %08X, %p)\n", wDevID, dwFlags, lpParms); if (!lpParms) return MCIERR_NULL_PARAMETER_BLOCK; wma = MCIQTZ_mciGetOpenDev(wDevID); if (!wma) return MCIERR_INVALID_DEVICE_ID; hr = IMediaControl_Run(wma->pmctrl); if (FAILED(hr)) { TRACE("Cannot run filtergraph (hr = %x)\n", hr); return MCIERR_INTERNAL; } if (!wma->parent) { IVideoWindow *vidwin; IFilterGraph2_QueryInterface(wma->pgraph, &IID_IVideoWindow, (void**)&vidwin); if (vidwin) { IVideoWindow_put_Visible(vidwin, OATRUE); IVideoWindow_Release(vidwin); } } return 0; }
/*************************************************************************** * MCIQTZ_mciStop [internal] */ static DWORD MCIQTZ_mciStop(UINT wDevID, DWORD dwFlags, LPMCI_GENERIC_PARMS lpParms) { WINE_MCIQTZ* wma; HRESULT hr; TRACE("(%04x, %08X, %p)\n", wDevID, dwFlags, lpParms); wma = MCIQTZ_mciGetOpenDev(wDevID); if (!wma) return MCIERR_INVALID_DEVICE_ID; if (!wma->opened) return 0; hr = IMediaControl_Stop(wma->pmctrl); if (FAILED(hr)) { TRACE("Cannot stop filtergraph (hr = %x)\n", hr); return MCIERR_INTERNAL; } if (!wma->parent) { IVideoWindow *vidwin; IFilterGraph2_QueryInterface(wma->pgraph, &IID_IVideoWindow, (void**)&vidwin); if (vidwin) { IVideoWindow_put_Visible(vidwin, OAFALSE); IVideoWindow_Release(vidwin); } } return 0; }
static void test_ifiltermapper_from_filtergraph(void) { IFilterGraph2* pgraph2 = NULL; IFilterMapper2 *pMapper2 = NULL; IFilterGraph *filtergraph = NULL; HRESULT hr; ULONG refcount; hr = CoCreateInstance(&CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, &IID_IFilterGraph2, (LPVOID*)&pgraph2); ok(hr == S_OK, "CoCreateInstance failed with %08x\n", hr); if (!pgraph2) goto out; hr = IFilterGraph2_QueryInterface(pgraph2, &IID_IFilterMapper2, (LPVOID*)&pMapper2); ok(hr == S_OK, "IFilterGraph2_QueryInterface failed with %08x\n", hr); if (!pMapper2) goto out; refcount = getRefcount((IUnknown*)pgraph2); ok(refcount == 2, "unexpected reference count: %u\n", refcount); refcount = getRefcount((IUnknown*)pMapper2); ok(refcount == 2, "unexpected reference count: %u\n", refcount); IFilterMapper2_AddRef(pMapper2); refcount = getRefcount((IUnknown*)pgraph2); ok(refcount == 3, "unexpected reference count: %u\n", refcount); refcount = getRefcount((IUnknown*)pMapper2); ok(refcount == 3, "unexpected reference count: %u\n", refcount); IFilterMapper2_Release(pMapper2); hr = IFilterMapper2_QueryInterface(pMapper2, &IID_IFilterGraph, (LPVOID*)&filtergraph); ok(hr == S_OK, "IFilterMapper2_QueryInterface failed with %08x\n", hr); if (!filtergraph) goto out; IFilterMapper2_Release(pMapper2); pMapper2 = NULL; IFilterGraph_Release(filtergraph); filtergraph = NULL; hr = CoCreateInstance(&CLSID_FilterMapper2, NULL, CLSCTX_INPROC_SERVER, &IID_IFilterMapper2, (LPVOID*)&pMapper2); ok(hr == S_OK, "CoCreateInstance failed with %08x\n", hr); if (!pMapper2) goto out; hr = IFilterMapper2_QueryInterface(pMapper2, &IID_IFilterGraph, (LPVOID*)&filtergraph); ok(hr == E_NOINTERFACE, "IFilterMapper2_QueryInterface unexpected result: %08x\n", hr); out: if (pMapper2) IFilterMapper2_Release(pMapper2); if (filtergraph) IFilterGraph_Release(filtergraph); if (pgraph2) IFilterGraph2_Release(pgraph2); }
/****************************************************************************** * MCIAVI_mciUpdate [internal] */ static DWORD MCIQTZ_mciUpdate(UINT wDevID, DWORD dwFlags, LPMCI_DGV_UPDATE_PARMS lpParms) { WINE_MCIQTZ *wma; DWORD res = 0; TRACE("%04x, %08x, %p\n", wDevID, dwFlags, lpParms); if (!lpParms) return MCIERR_NULL_PARAMETER_BLOCK; wma = MCIQTZ_mciGetOpenDev(wDevID); if (!wma) return MCIERR_INVALID_DEVICE_ID; if (dwFlags & MCI_DGV_UPDATE_HDC) { IBasicVideo *vidbasic; IVideoWindow *vidwin; res = MCIERR_INTERNAL; IFilterGraph2_QueryInterface(wma->pgraph, &IID_IVideoWindow, (void**)&vidwin); IFilterGraph2_QueryInterface(wma->pgraph, &IID_IBasicVideo, (void**)&vidbasic); if (vidbasic && vidwin) { LONG state, size; BYTE *data; BITMAPINFO *info; HRESULT hr; RECT src, dest; /* If in stopped state, nothing has been drawn to screen * moving to pause, which is needed for the old dib renderer, will result * in a single frame drawn, so hide the window here */ IVideoWindow_put_Visible(vidwin, OAFALSE); /* FIXME: Should we check the original state and restore it? */ IMediaControl_Pause(wma->pmctrl); IMediaControl_GetState(wma->pmctrl, -1, &state); if (FAILED(hr = IBasicVideo_GetCurrentImage(vidbasic, &size, NULL))) { WARN("Could not get image size (hr = %x)\n", hr); goto out; } data = HeapAlloc(GetProcessHeap(), 0, size); info = (BITMAPINFO*)data; IBasicVideo_GetCurrentImage(vidbasic, &size, (LONG*)data); data += info->bmiHeader.biSize; IBasicVideo_GetSourcePosition(vidbasic, &src.left, &src.top, &src.right, &src.bottom); IBasicVideo_GetDestinationPosition(vidbasic, &dest.left, &dest.top, &dest.right, &dest.bottom); StretchDIBits(lpParms->hDC, dest.left, dest.top, dest.right + dest.left, dest.bottom + dest.top, src.left, src.top, src.right + src.left, src.bottom + src.top, data, info, DIB_RGB_COLORS, SRCCOPY); HeapFree(GetProcessHeap(), 0, data); } res = 0; out: if (vidbasic) IBasicVideo_Release(vidbasic); if (vidwin) { if (wma->parent) IVideoWindow_put_Visible(vidwin, OATRUE); IVideoWindow_Release(vidwin); } } else if (dwFlags) FIXME("Unhandled flags %x\n", dwFlags); return res; }
/*************************************************************************** * MCIQTZ_mciOpen [internal] */ static DWORD MCIQTZ_mciOpen(UINT wDevID, DWORD dwFlags, LPMCI_DGV_OPEN_PARMSW lpOpenParms) { WINE_MCIQTZ* wma; HRESULT hr; IBasicVideo *vidbasic; IVideoWindow *vidwin; TRACE("(%04x, %08X, %p)\n", wDevID, dwFlags, lpOpenParms); if (!lpOpenParms) return MCIERR_NULL_PARAMETER_BLOCK; wma = MCIQTZ_mciGetOpenDev(wDevID); if (!wma) return MCIERR_INVALID_DEVICE_ID; MCIQTZ_mciStop(wDevID, MCI_WAIT, NULL); hr = CoInitializeEx(NULL, COINIT_MULTITHREADED); wma->uninit = SUCCEEDED(hr); hr = CoCreateInstance(&CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, &IID_IGraphBuilder, (LPVOID*)&wma->pgraph); if (FAILED(hr)) { TRACE("Cannot create filtergraph (hr = %x)\n", hr); goto err; } hr = IGraphBuilder_QueryInterface(wma->pgraph, &IID_IMediaControl, (LPVOID*)&wma->pmctrl); if (FAILED(hr)) { TRACE("Cannot get IMediaControl interface (hr = %x)\n", hr); goto err; } if (!(dwFlags & MCI_OPEN_ELEMENT) || (dwFlags & MCI_OPEN_ELEMENT_ID)) { TRACE("Wrong dwFlags %x\n", dwFlags); goto err; } if (!lpOpenParms->lpstrElementName || !lpOpenParms->lpstrElementName[0]) { TRACE("Invalid filename specified\n"); goto err; } TRACE("Open file %s\n", debugstr_w(lpOpenParms->lpstrElementName)); hr = IGraphBuilder_RenderFile(wma->pgraph, lpOpenParms->lpstrElementName, NULL); if (FAILED(hr)) { TRACE("Cannot render file (hr = %x)\n", hr); goto err; } hr = IFilterGraph2_QueryInterface(wma->pgraph, &IID_IVideoWindow, (void**)&vidwin); if (SUCCEEDED(hr)) hr = IFilterGraph2_QueryInterface(wma->pgraph, &IID_IBasicVideo, (void**)&vidbasic); if (SUCCEEDED(hr)) { DWORD style; RECT rc = { 0, 0, 0, 0 }; IVideoWindow_put_AutoShow(vidwin, OAFALSE); IVideoWindow_put_Visible(vidwin, OAFALSE); style = 0; if (dwFlags & MCI_DGV_OPEN_WS) style |= lpOpenParms->dwStyle; if (dwFlags & MCI_DGV_OPEN_PARENT) { IVideoWindow_put_MessageDrain(vidwin, (OAHWND)lpOpenParms->hWndParent); IVideoWindow_put_WindowState(vidwin, SW_HIDE); IVideoWindow_put_WindowStyle(vidwin, WS_CHILD); IVideoWindow_put_Owner(vidwin, (OAHWND)lpOpenParms->hWndParent); wma->parent = (HWND)lpOpenParms->hWndParent; } else if (style) IVideoWindow_put_WindowStyle(vidwin, style); IBasicVideo_GetVideoSize(vidbasic, &rc.right, &rc.bottom); IVideoWindow_SetWindowPosition(vidwin, rc.left, rc.top, rc.right, rc.bottom); IBasicVideo_Release(vidbasic); } if (vidwin) IVideoWindow_Release(vidwin); wma->opened = TRUE; if (dwFlags & MCI_NOTIFY) mciDriverNotify(HWND_32(LOWORD(lpOpenParms->dwCallback)), wDevID, MCI_NOTIFY_SUCCESSFUL); return 0; err: if (wma->pgraph) IGraphBuilder_Release(wma->pgraph); wma->pgraph = NULL; if (wma->pmctrl) IMediaControl_Release(wma->pmctrl); wma->pmctrl = NULL; if (wma->uninit) CoUninitialize(); return MCIERR_INTERNAL; }