#if 1 /* for VIVO cards we should check if preview pin is available on video capture device. If it is not, we have to connect Video Port Manager filter to VP pin of capture device filter. Otherwise we will get 0x8007001f (Device is not functioning properly) when attempting to start graph */ typedef struct ITypeInfo ITypeInfo; typedef struct _IVideoWindow IVideoWindow; typedef LONG_PTR OAHWND; typedef struct IVideoWindow_vt{ INHERIT_IUNKNOWN(); HRESULT STDCALL (*GetTypeInfoCount )(IVideoWindow * This,UINT *pctinfo); HRESULT STDCALL (*GetTypeInfo )(IVideoWindow * This,UINT iTInfo,LCID lcid,ITypeInfo **ppTInfo); HRESULT STDCALL (*GetIDsOfNames )( IVideoWindow * This,REFIID riid,LPOLESTR *rgszNames,UINT cNames,LCID lcid,DISPID *rgDispId); HRESULT STDCALL (*Invoke )( IVideoWindow * This,DISPID dispIdMember,REFIID riid,LCID lcid,WORD wFlags,void *pDispParams,VARIANT *pVarResult,EXCEPINFO *pExcepInfo,UINT *puArgErr); HRESULT STDCALL (*put_Caption )( IVideoWindow * This,BSTR strCaption); HRESULT STDCALL (*get_Caption )( IVideoWindow * This,BSTR *strCaption); HRESULT STDCALL (*put_WindowStyle )( IVideoWindow * This,long WindowStyle); HRESULT STDCALL (*get_WindowStyle )( IVideoWindow * This,long *WindowStyle); HRESULT STDCALL (*put_WindowStyleEx )( IVideoWindow * This,long WindowStyleEx); HRESULT STDCALL (*get_WindowStyleEx )( IVideoWindow * This,long *WindowStyleEx); HRESULT STDCALL (*put_AutoShow )( IVideoWindow * This,long AutoShow); HRESULT STDCALL (*get_AutoShow )( IVideoWindow * This,long *AutoShow); HRESULT STDCALL (*put_WindowState )( IVideoWindow * This,long WindowState); HRESULT STDCALL (*get_WindowState )( IVideoWindow * This,long *WindowState); HRESULT STDCALL (*put_BackgroundPalette )( IVideoWindow * This,long BackgroundPalette); HRESULT STDCALL (*get_BackgroundPalette )( IVideoWindow * This,long *pBackgroundPalette); HRESULT STDCALL (*put_Visible )( IVideoWindow * This,long Visible); HRESULT STDCALL (*get_Visible )( IVideoWindow * This,long *pVisible); HRESULT STDCALL (*put_Left )( IVideoWindow * This,long Left); HRESULT STDCALL (*get_Left )( IVideoWindow * This,long *pLeft); HRESULT STDCALL (*put_Width )( IVideoWindow * This,long Width); HRESULT STDCALL (*get_Width )( IVideoWindow * This,long *pWidth); HRESULT STDCALL (*put_Top )( IVideoWindow * This,long Top); HRESULT STDCALL (*get_Top )( IVideoWindow * This,long *pTop); HRESULT STDCALL (*put_Height )( IVideoWindow * This,long Height); HRESULT STDCALL (*get_Height )( IVideoWindow * This,long *pHeight); HRESULT STDCALL (*put_Owner )( IVideoWindow * This,OAHWND Owner); HRESULT STDCALL (*get_Owner )( IVideoWindow * This,OAHWND *Owner); HRESULT STDCALL (*put_MessageDrain )( IVideoWindow * This,OAHWND Drain); HRESULT STDCALL (*get_MessageDrain )( IVideoWindow * This,OAHWND *Drain); HRESULT STDCALL (*get_BorderColor )( IVideoWindow * This,long *Color); HRESULT STDCALL (*put_BorderColor )( IVideoWindow * This,long Color); HRESULT STDCALL (*get_FullScreenMode )( IVideoWindow * This,long *FullScreenMode); HRESULT STDCALL (*put_FullScreenMode )( IVideoWindow * This,long FullScreenMode); HRESULT STDCALL ( *SetWindowForeground )( IVideoWindow * This,long Focus); HRESULT STDCALL ( *NotifyOwnerMessage )( IVideoWindow * This,OAHWND hwnd,long uMsg,LONG_PTR wParam,LONG_PTR lParam); HRESULT STDCALL ( *SetWindowPosition )( IVideoWindow * This,long Left,long Top,long Width,long Height); HRESULT STDCALL ( *GetWindowPosition )( IVideoWindow * This,long *pLeft,long *pTop,long *pWidth,long *pHeight); HRESULT STDCALL ( *GetMinIdealImageSize )( IVideoWindow * This,long *pWidth,long *pHeight); HRESULT STDCALL ( *GetMaxIdealImageSize )( IVideoWindow * This,long *pWidth,long *pHeight); HRESULT STDCALL ( *GetRestorePosition )( IVideoWindow * This,long *pLeft,long *pTop,long *pWidth,long *pHeight); HRESULT STDCALL ( *HideCursor )( IVideoWindow * This,long HideCursor); HRESULT STDCALL ( *IsCursorHidden )( IVideoWindow * This,long *CursorHidden); } IVideoWindow_vt; struct _IVideoWindow {struct IVideoWindow_vt *vt;}; typedef struct IEnumFilters_vt{ INHERIT_IUNKNOWN(); HRESULT STDCALL (*Next )( IEnumFilters * This,ULONG cFilters,IBaseFilter **ppFilter,ULONG *pcFetched); HRESULT STDCALL (*Skip )( IEnumFilters * This,ULONG cFilters); HRESULT STDCALL (*Reset )( IEnumFilters * This); HRESULT STDCALL (*Clone )( IEnumFilters * This,IEnumFilters **ppEnum); } IEnumFilters_vt; struct _IEnumFilters {struct IEnumFilters_vt *vt;}; const GUID IID_IVideoWindow={0x56a868b4,0x0ad4,0x11ce,{0xb0,0x3a,0x00,0x20,0xaf,0x0b,0xa7,0x70}}; void hide_video_window(priv_t* priv){ IEnumFilters* pEnum; IBaseFilter* pFilter=NULL; IVideoWindow* pVideoWindow; priv->pGraph->vt->EnumFilters(priv->pGraph,&pEnum); while(pEnum->vt->Next(pEnum,1,&pFilter,NULL)==S_OK) { if(SUCCEEDED(pFilter->vt->QueryInterface(pFilter,&IID_IVideoWindow,&pVideoWindow))){ pVideoWindow->vt->put_Visible(pVideoWindow,-1 /*OATRUE*/); pVideoWindow->vt->put_AutoShow(pVideoWindow,-1 /*OATRUE*/); pVideoWindow->vt->Release(pVideoWindow); } pFilter->vt->Release(pFilter); } pEnum->vt->Release(pEnum); } HRESULT connect_vp_pin(priv_t* priv){ HRESULT hr; IPin* pPreviewPin=NULL; IPin* pVPOutPin=NULL; for(;;){ /* connecting VP pin is required only for VIVO cards with VP and without Preview pins. */ hr=priv->pBuilder->vt->FindPin(priv->pBuilder,(IUnknown*)priv->pVideoFilter,PINDIR_OUTPUT,&PIN_CATEGORY_PREVIEW,NULL,FALSE,0,(IPin**)&pPreviewPin); if (hr==S_OK) { pPreviewPin->vt->Release((IUnknown*)pPreviewPin); break; // Video capture device has preview pin. No action is required } hr=priv->pBuilder->vt->FindPin(priv->pBuilder,(IUnknown*)priv->pVideoFilter,PINDIR_OUTPUT,&PIN_CATEGORY_VIDEOPORT,NULL,FALSE,0,(IPin**)&pVPOutPin); if (FAILED(hr)) { hr=S_OK; // Video capture device has no VideoPort pin. No action is required in this case break; } mp_msg(MSGT_TV,MSGL_V,"Video capture device has VidePort pin and no Preview pin. Conecting VideoPort pin to Video Port Manager filter.\n"); hr=priv->pBuilder->vt->RenderStream(priv->pBuilder,&PIN_CATEGORY_VIDEOPORT, NULL,priv->pVideoFilter, NULL, NULL); if (FAILED(hr)){ showError("RenderStream(Capture,NULL,NULL) failed","connect_vp_pin",hr); break; } hide_video_window(priv); } if (pVPOutPin) pVPOutPin->vt->Release((IUnknown*)pVPOutPin); if (pPreviewPin) pPreviewPin->vt->Release((IUnknown*)pPreviewPin); return hr; } #endif