/// <summary> /// Add VMR7 filter to graph and configure it /// </summary> /// <param name="graphBuilder"></param> public void AddVMR7(IGraphBuilder graphBuilder) { Log.Info("VMR7Helper:AddVMR7"); if (vmr7intialized) { return; } VMR7Filter = (IBaseFilter) new VideoMixingRenderer(); if (VMR7Filter == null) { Error.SetError("Unable to play movie", "VMR7 is not installed"); Log.Error("VMR7Helper:Failed to get instance of VMR7 "); return; } int hr; IVMRFilterConfig config = VMR7Filter as IVMRFilterConfig; if (config != null) { hr = config.SetNumberOfStreams(1); if (hr != 0) { Log.Error("VMR7Helper:Failed to set number of streams:0x{0:X}", hr); DirectShowUtil.ReleaseComObject(VMR7Filter); VMR7Filter = null; return; } } hr = graphBuilder.AddFilter(VMR7Filter, "Video Mixing Renderer"); if (hr != 0) { Error.SetError("Unable to play movie", "Unable to initialize VMR7"); Log.Error("VMR7Helper:Failed to add VMR7 to filtergraph"); DirectShowUtil.ReleaseComObject(VMR7Filter); VMR7Filter = null; return; } m_graphBuilder = graphBuilder; m_mixerBitmap = VMR7Filter as IVMRMixerBitmap; quality = VMR7Filter as IQualProp; g_vmr7 = this; vmr7intialized = true; }
public void BuildGraph() { int hr = 0; graphBuilder = (IFilterGraph2) new FilterGraph(); rot = new DsROTEntry(graphBuilder); vmr = (IBaseFilter) new VideoMixingRenderer(); IVMRFilterConfig filterConfig = (IVMRFilterConfig)vmr; hr = filterConfig.SetNumberOfStreams(2); DsError.ThrowExceptionForHR(hr); // Put the VMR7 in Renderless mode hr = filterConfig.SetRenderingMode(VMRMode.Renderless); DsError.ThrowExceptionForHR(hr); surfaceAllocatorNotify = (IVMRSurfaceAllocatorNotify)vmr; hr = surfaceAllocatorNotify.AdviseSurfaceAllocator(cookie, this); DsError.ThrowExceptionForHR(hr); defaultAllocatorPresenter = (IVMRSurfaceAllocator)Activator.CreateInstance(Type.GetTypeFromCLSID(VMRClsId.AllocPresenter)); form = new Form(); form.Show(); hr = (defaultAllocatorPresenter as IVMRWindowlessControl).SetVideoClippingWindow(form.Handle); DsError.ThrowExceptionForHR(hr); hr = this.AdviseNotify(surfaceAllocatorNotify); DsError.ThrowExceptionForHR(hr); hr = graphBuilder.AddFilter(vmr, "VMR"); hr = graphBuilder.RenderFile(@"..\..\..\Resources\foo.avi", null); DsError.ThrowExceptionForHR(hr); }
public void BuildGraph() { int hr = 0; graphBuilder = (IFilterGraph2) new FilterGraph(); rot = new DsROTEntry(graphBuilder); vmr = (IBaseFilter) new VideoMixingRenderer(); IVMRFilterConfig filterConfig = (IVMRFilterConfig)vmr; hr = filterConfig.SetNumberOfStreams(2); DsError.ThrowExceptionForHR(hr); // Set the custom compositor hr = filterConfig.SetImageCompositor(this); DsError.ThrowExceptionForHR(hr); IVMRMixerControl mixerControl = (IVMRMixerControl)vmr; // In COLORREF, colors are coded in ABGR format hr = mixerControl.SetBackgroundClr(backgroundColorABGR); DsError.ThrowExceptionForHR(hr); hr = graphBuilder.AddFilter(vmr, "VMR"); DsError.ThrowExceptionForHR(hr); // The 2 VMR pins must be connected... hr = graphBuilder.RenderFile(@"..\..\..\Resources\foo.avi", null); DsError.ThrowExceptionForHR(hr); hr = graphBuilder.RenderFile(@"..\..\..\Resources\foo.avi", null); DsError.ThrowExceptionForHR(hr); hr = (graphBuilder as IMediaControl).Run(); DsError.ThrowExceptionForHR(hr); }