private void timerCheck_Tick(object sender, EventArgs e) { bool bActive = false; if (m_pFilter != null) { FilterState _state; if (HRESULT.S_OK == m_pFilter.GetState(100, out _state)) { bActive = (_state == FilterState.Stopped); } } cmboProfile.Enabled = bActive; cmboLevel.Enabled = bActive; cmboRateControl.Enabled = bActive; cmboMBEncoding.Enabled = bActive; cbGOP.Enabled = bActive; cbDeblocking.Enabled = bActive; cbAutoBitrate.Enabled = bActive; tbBitrate.Enabled = bActive; tbIDRPeriod.Enabled = bActive; tbPPeriod.Enabled = bActive; }
public void UpdateState() { basefilter.GetState(20, out filterState); }
/// <summary> build the capture graph for grabber. </summary> bool SetupGraph() { int hr; IPin pin1, pin2; try { hr = capGraph.SetFiltergraph(graphBuilder); if (hr < 0) { Marshal.ThrowExceptionForHR(hr); } if (atiTVCardFound) { SetupVideoCrossbar(); AddFilter(atiCrossbar, "ATI Crossbar"); AddFilter(capFilter, "Analog Capture Device"); AddFilter(wmVideoDecoder, "AVI Decompressor"); AddFilter(stretchVideo, "Stretch Video"); AddFilter(colorConverter, "Color Space Converter"); } else if (videoSource.Equals("File")) { graphBuilder.AddSourceFilter(filePath, "WM ASF Reader", out capFilter); AddFilter(modFrameRate, "Modify Frame Rate"); AddFilter(stretchVideo, "Stretch Video"); AddFilter(colorConverter, "Color Space Converter"); } else { int state; if (capFilter.GetState(100, out state) == 0) { AddFilter(capFilter, "Capture Filter"); } } AddFilter(sampleGrabber, "Sample Grabber"); // make sure samples grabbed have 32 bits per pixel to work with Ge Force 7900 AddFilter(baseGrabFlt, "Vector Grabber"); AddFilter(motionVector, "Motion Flow Vector Filter"); if (videoPreview) { AddFilter(teeSplitter, "Smart Tee Splitter"); AddFilter(colorConverter, "Color Space Converter"); AddFilter(videoRenderer, "Video Renderer"); } #if false // Attempt to use VMR9 abandoned for now IVMRFilterConfig9 vmrConfig = videoRenderer as IVMRFilterConfig9; hr = vmrConfig.SetRenderingMode(VMR9Mode.Renderless); if (hr < 0) { Marshal.ThrowExceptionForHR(hr); } IVMRSurfaceAllocatorNotify9 vmrAllocNotify = videoRenderer as IVMRSurfaceAllocatorNotify9; vmrAllocNotify.AdviseSurfaceAllocator(userID, vmrAllocator); vmrAllocator.AdviseNotify(vmrAllocNotify); #endif // connect the pins if (videoSource.Equals("File")) { ConnectPins(capFilter, "Raw Video 1", modFrameRate, "In"); ConnectPins(modFrameRate, "Out", stretchVideo, "In"); //ConnectPins(wmVideoDecoder, "out0", stretchVideo, "In"); ConnectPins(stretchVideo, "Out", colorConverter, "In"); ConnectPins(colorConverter, "Out", sampleGrabber, "In"); } else { if (atiTVCardFound) { ConnectPins(atiCrossbar, "0: Video Decoder Out", capFilter, "0"); ConnectPins(capFilter, "2", wmVideoDecoder, "In"); ConnectPins(wmVideoDecoder, "Out", stretchVideo, "In"); ConnectPins(stretchVideo, "Out", colorConverter, "In"); ConnectPins(colorConverter, "Out", sampleGrabber, "In"); } else // webcam case { //ConnectPins(capFilter, "CapturePin", stretchVideo, "In"); ConnectPins(capFilter, "CapturePin", sampleGrabber, "In"); } } if (videoPreview) { ConnectPins(sampleGrabber, "Out", teeSplitter, "Input"); //ConnectPins(teeSplitter, "0", videoRenderer, "In"); ConnectPins(teeSplitter, "Preview", colorConverter, "In"); ConnectPins(colorConverter, "Out", videoRenderer, "VMR Input0"); ConnectPins(teeSplitter, "Capture", motionVector, "In"); } else { ConnectPins(sampleGrabber, "Out", motionVector, "In"); } ConnectPins(motionVector, "Out", baseGrabFlt, "In"); // check that all filters are accounted for // there must be a total of 7 filters if source is "File" IEnumFilters enumFilters; graphBuilder.EnumFilters(out enumFilters); enumFilters.Reset(); IBaseFilter[] filters = new IBaseFilter[1]; int count = 0; int total = 0; while (0 == (hr = enumFilters.Next(1, filters, out count))) { FilterInfo info = new FilterInfo(); hr = filters[0].QueryFilterInfo(info); if (hr < 0) { Marshal.ThrowExceptionForHR(hr); } LogInfo(LogGroups.Console, info.achName); IPin[] pins = new IPin[1]; IEnumPins enumPins; filters[0].EnumPins(out enumPins); while (0 == (hr = enumPins.Next(1, pins, out count))) { IPin pin; hr = pins[0].ConnectedTo(out pin); if (pin != null) { string pinID; hr = pin.QueryId(out pinID); LogInfo(LogGroups.Console, pinID); } } Marshal.ReleaseComObject(filters[0]); total++; } Marshal.ReleaseComObject(enumFilters); SetupVideoGrabber(); SetupVectorGrabber(); return(true); } catch (Exception ee) { LogInfo(LogGroups.Console, "Could not setup graph\r\n" + ee.Message); return(false); } }