Exemple #1
0
        public static Graph BuildFilterGraphForFiles(String[] fileNames)
        {
            IGraphBuilder builder = CreateGraphBuilder();

            int hr;
            foreach (String fileName in fileNames)
            {
                hr = builder.RenderFile(fileName, null);
                DsError.ThrowExceptionForHR(hr);
            }

            IEnumFilters filtersEnum;
            hr = builder.EnumFilters(out filtersEnum);
            DsError.ThrowExceptionForHR(hr);

            IBaseFilter[] filters = new IBaseFilter[1];
            IntPtr count = Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(ulong)));

            try
            {
                Graph graph = new Graph();

                while ((hr = filtersEnum.Next(1, filters, count)) == 0)
                {
                    IBaseFilter filter = filters[0];

                    graph.AddFilter(new Filter(graph, filter));
                }

                return graph;
            }
            finally
            {
                Marshal.FreeCoTaskMem(count);
                count = IntPtr.Zero;
            }
        }
Exemple #2
0
 internal Filter(Graph graph, IBaseFilter filter)
 {
     _graph = graph;
     _filter = filter;
     _fileSourceFilter = filter as IFileSourceFilter;
 }