/// <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 = graphStorage.CreateStream("ActiveMovieGraph", (int)(STGM_WRITE | STGM_CREATE | STGM_SHARE_EXCLUSIVE), 0, 0); dc.Add(stream); // Save out the graph and commit it ps.Save(stream, true); graphStorage.Commit(0); } }
/// <summary>Runs the conversion synchronously.</summary> /// <returns>The result of the conversion.</returns> public object Convert() { _cancellationPending = false; try { object result; using(_dc = new DisposalCleanup()) { // Do the actual work result = DoWork(); } OnConversionComplete(null, result); return result; } catch(DirectShowException exc) { OnConversionComplete(exc, null); throw; } catch(Exception exc) { exc = new DirectShowException(exc); OnConversionComplete(exc, null); throw exc; } }