public void Reset() { sampleIndex = 0; sampleProcessed = 0; sampleDropped = 0; mediaState = null; bProcess = true; lastMediaTime = -1; sample.Buffer = null; if (sample.UnmanagedBuffer != null) { sample.UnmanagedBuffer.Release(); } sample.UnmanagedBuffer = null; }
} // EnumInputDev private int InitInputDev(MediaState ms, DevItem videoItem, DevItem audioItem) { int hr = 0; // create Filter Graph Manager if (ms.graph == null) { //ms.graph = new FilterGraph() as IGraphBuilder; ms.graph = new FilterGraph() as IFilterGraph2; if (ms.graph == null) { throw new COMException("Cannot create FilterGraph"); } ms.captureGraph = new CaptureGraphBuilder2() as ICaptureGraphBuilder2; if (ms.captureGraph == null) { throw new COMException("Cannot create CaptureGraphBuilder2"); } hr = ms.captureGraph.SetFiltergraph(ms.graph); DsError.ThrowExceptionForHR(hr); } if (audioItem != null) { // remove the old audio input if (ms.audioInput != null) { hr = ms.graph.RemoveFilter(ms.audioInput); Util.ReleaseComObject(ref ms.audioInput); DsError.ThrowExceptionForHR(hr); } // create audio input if (!audioItem.Disabled) { // using BindToMoniker ms.audioInput = Marshal.BindToMoniker(audioItem.DisplayName) as IBaseFilter; // add audio input to the graph hr = ms.graph.AddFilter(ms.audioInput, audioItem.FriendlyName); DsError.ThrowExceptionForHR(hr); } } if (videoItem != null) { // remove the old video input if (ms.videoInput != null) { hr = ms.graph.RemoveFilter(ms.videoInput); Util.ReleaseComObject(ref ms.videoInput); DsError.ThrowExceptionForHR(hr); } // create video input // Using BindToMoniker ms.videoInput = Marshal.BindToMoniker(videoItem.DisplayName) as IBaseFilter; // add video input to the graph hr = ms.graph.AddFilter(ms.videoInput, videoItem.FriendlyName); DsError.ThrowExceptionForHR(hr); } return(hr); }