public virtual bool Open(Filters.Abstract recipe) { this.graph = new DirectShowLib.FilterGraph() as DirectShowLib.IFilterGraph2; DirectShowLib.IMediaEventEx mediaEvent = this.graph as DirectShowLib.IMediaEventEx; if (mediaEvent.NotNull()) { if (this.eventPoller.NotNull()) { this.eventPoller.Dispose(); } this.eventPoller = Parallel.RepeatThread.Start("DS Event Poller", () => { DirectShowLib.EventCode code; IntPtr parameter1, parameter2; if (mediaEvent.GetEvent(out code, out parameter1, out parameter2, 960) == 0) { switch (code) { default: Error.Log.Append(Error.Level.Debug, "DirectShow Event: " + code, "DirectShow event " + code + " occured. (paramenter1: " + parameter1 + ", paramenter2: " + parameter2 + ")"); break; case DirectShowLib.EventCode.GraphChanged: Error.Log.Append(Error.Level.Debug, "DirectShow Event: Graph Changed", "The DirectShow graph has changed."); break; case DirectShowLib.EventCode.Paused: Error.Log.Append(Error.Level.Debug, "DirectShow Event: Paused", "The DirectShow graph has completed a pause request."); break; case DirectShowLib.EventCode.ClockChanged: Error.Log.Append(Error.Level.Debug, "DirectShow Event: Clock Changed", "The DirectShow graph has changed the reference clock."); break; case DirectShowLib.EventCode.StErrStPlaying: Error.Log.Append(Error.Level.Debug, "DirectShow Event: Stream Error, Still Playing", "A stream error occured, trying to recover by issuing stop followed by play. (paramenter: " + parameter1 + ")"); this.Stop(); this.Play(); break; } } }); } return(recipe.Build(this)); }
public virtual void Close() { if (this.graph is DirectShowLib.IMediaControl) { this.Stop(); this.onClose.Call(); this.onClose = null; this.Send = null; if (this.eventPoller.NotNull()) { this.eventPoller.Abort(); this.eventPoller = null; } Exception.GraphError.Check((this.graph as DirectShowLib.IMediaControl).StopWhenReady()); Exception.GraphError.Check(this.graph.Abort()); //System.Runtime.InteropServices.Marshal.ReleaseComObject(this.graph); this.graph = null; } }
public virtual bool Open(Filters.Abstract recipe) { this.graph = new DirectShowLib.FilterGraph() as DirectShowLib.IFilterGraph2; DirectShowLib.IMediaEventEx mediaEvent = this.graph as DirectShowLib.IMediaEventEx; if (mediaEvent.NotNull()) { if (this.eventPoller.NotNull()) this.eventPoller.Dispose(); this.eventPoller = Parallel.RepeatThread.Start("DS Event Poller", () => { DirectShowLib.EventCode code; IntPtr parameter1, parameter2; if (mediaEvent.GetEvent(out code, out parameter1, out parameter2, 960) == 0) { switch (code) { default: Error.Log.Append(Error.Level.Debug, "DirectShow Event: " + code, "DirectShow event " + code + " occured. (paramenter1: " + parameter1 + ", paramenter2: " + parameter2 + ")"); break; case DirectShowLib.EventCode.GraphChanged: Error.Log.Append(Error.Level.Debug, "DirectShow Event: Graph Changed", "The DirectShow graph has changed."); break; case DirectShowLib.EventCode.Paused: Error.Log.Append(Error.Level.Debug, "DirectShow Event: Paused", "The DirectShow graph has completed a pause request."); break; case DirectShowLib.EventCode.ClockChanged: Error.Log.Append(Error.Level.Debug, "DirectShow Event: Clock Changed", "The DirectShow graph has changed the reference clock."); break; case DirectShowLib.EventCode.StErrStPlaying: Error.Log.Append(Error.Level.Debug, "DirectShow Event: Stream Error, Still Playing", "A stream error occured, trying to recover by issuing stop followed by play. (paramenter: " + parameter1 + ")"); this.Stop(); this.Play(); break; } } }); } return recipe.Build(this); }