// Constructor public DSTranscoderBase() { // Create a new filter graph to work with, and ensure it's disposed when this object is dc = new DisposalCleanup(); currentFilterGraph = (IFilterGraph)new FilterGraph(); dc.Add(currentFilterGraph); CreationDate = DateTime.Now; }
protected DisposalCleanup dc; // A class written by Stephen Toub to aid in cleanup / release of COM objects // Constructor public DSTranscoderBase() { // Create a new filter graph to work with, and ensure it's disposed when this object is dc = new DisposalCleanup(); currentFilterGraph = (IFilterGraph) new FilterGraph(); dc.Add(currentFilterGraph); CreationDate = DateTime.Now; }
/// <summary>Saves a graph to a GRF file.</summary> /// <param name="graph">The graph to be saved.</param> /// <param name="path">Path to the target GRF file.</param> private static void SaveGraphToFile(IGraphBuilder graph, string path) { using (DisposalCleanup dc = new DisposalCleanup()) { // Get the graph's persist stream interface IPersistStream ps = (IPersistStream)graph; // Create the file to which the graph should be stored IStorage graphStorage = StgCreateDocfile(path, (int)(STGM_CREATE | STGM_TRANSACTED | STGM_READWRITE | STGM_SHARE_EXCLUSIVE), 0); dc.Add(graphStorage); // Create the movie graph stream IStream stream; int hr = graphStorage.CreateStream("ActiveMovieGraph", (STGM)(STGM.Write | STGM.Create | STGM.ShareExclusive), 0, 0, out stream); dc.Add(stream); // Save out the graph and commit it ps.Save(stream, true); graphStorage.Commit(0); } }