Пример #1
0
        public void ReloadName()
        {
            try
            {
                if (basefilter == null)
                {
                    return;
                }
                FilterInfo fi;
                basefilter.QueryFilterInfo(out fi);
                name    = fi.achName;
                orgname = fi.achName;

                IFileSourceFilter fsrc = basefilter as IFileSourceFilter;
                if (fsrc != null && fsrc.GetCurFile(out srcfilename, null) == 0 && srcfilename != null && !name.Contains(srcfilename))
                {
                    name += " " + srcfilename.Substring(srcfilename.LastIndexOf('\\') + 1);
                }

                IFileSinkFilter fdst = basefilter as IFileSinkFilter;
                if (fdst != null && fdst.GetCurFile(out dstfilename, null) == 0 && dstfilename != null && !name.Contains(dstfilename))
                {
                    name += " " + dstfilename.Substring(dstfilename.LastIndexOf('\\') + 1);
                }

                string dspname = filterProps.DisplayName;
                if (dspname != null && dspname.Length > 0)
                {
                    if (!dispnames.ContainsKey(orgname))
                    {
                        dispnames.Add(orgname, dspname);
                    }
                }
                else //have no display name
                {
                    if (dispnames.TryGetValue(orgname, out dspname))
                    {
                        filterProps.DisplayName = dspname;
                    }
                }

                IVideoWindow vw = basefilter as IVideoWindow;
                if (vw != null)
                {
                    //string s;
                    //vw.get_Caption(out s);
                    string gname = Graph.Form.Text + ": " + name;// +": ";
                    vw.put_Caption(gname);
                    //vw.SetWindowForeground(OABool.False);
                    //vw.put_AutoShow(OABool.True);
                    //vw.put_Owner(Program.mainform.Handle); hangs
                    WindowStyleEx wex;
                    vw.get_WindowStyleEx(out wex);
                    vw.put_WindowStyleEx(wex | WindowStyleEx.Topmost);
                }
            }
            catch (COMException e)
            {
                Graph.ShowCOMException(e, "Problem occured while examining filter " + Name);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, "Exception caught while examining filter " + Name);
            }
        }
Пример #2
0
        public static string DumpFilterInfo(IBaseFilter filter)
        {
            StringBuilder sb = new StringBuilder();

            int hr;

            sb.AppendLine(">>>>>>> BaseFilter info dump BEGIN");

            {
                Guid guid;
                hr = filter.GetClassID(out guid);
                if (0 == hr)
                {
                    sb.AppendLine("ClassID: " + guid.ToString());
                }
                else
                {
                    sb.AppendLine("ClassID: " + GetErrorText(hr));
                }
            }

            {
                string vendorInfo = null;
                hr = filter.QueryVendorInfo(out vendorInfo);
                if (0 == hr)
                {
                    sb.AppendLine(string.Format("VendorInfo: {0}", vendorInfo));
                }
                else
                {
                    sb.AppendLine("VendorInfo: " + GetErrorText(hr));
                }
            }

            {
                FilterInfo fi;
                hr = filter.QueryFilterInfo(out fi);
                if (0 == hr)
                {
                    sb.AppendLine(string.Format("FilterInfo achName: {0}", fi.achName));
                }
                else
                {
                    sb.AppendLine("FilterInfo achName: " + GetErrorText(hr));
                }
            }

            IFileSourceFilter fileSourceFilter = filter as IFileSourceFilter;

            if (fileSourceFilter != null)
            {
                string      fileName;
                AMMediaType mt = new AMMediaType();
                fileSourceFilter.GetCurFile(out fileName, mt);
                DsUtils.FreeAMMediaType(mt);
                sb.AppendLine("IFileSourceFilter CurFile: " + fileName);
            }

            // Pins info
            {
                IEnumPins enumPins = null;
                IPin[]    pins     = new IPin[1] {
                    null
                };

                try
                {
                    hr = filter.EnumPins(out enumPins);
                    DsError.ThrowExceptionForHR(hr);

                    while (enumPins.Next(1, pins, IntPtr.Zero) == 0)
                    {
                        sb.AppendLine(DumpPinInfo(pins[0]));
                        Util.ReleaseComObject(ref pins[0]);
                    }
                }
                finally
                {
                    Marshal.ReleaseComObject(enumPins);
                }
            }

            sb.AppendLine(">>>>>>> BaseFilter info dump END");

            return(sb.ToString());
        }
Пример #3
0
        public DSFilterNode(IBaseFilter filter, bool manualAdded)
        {
            _filter      = filter;
            _manualAdded = manualAdded;

            AssociatedUINode = typeof(DSFilterNodeUI).AssemblyQualifiedName;

            // if it's a filesource filter, get the filename for it
            IFileSourceFilter fs = filter as IFileSourceFilter;

            if (fs != null)
            {
                IAMOpenProgress op = filter as IAMOpenProgress;
                if (op != null)
                {
                    // it wants a URL (thought you were being sneaky huh?)
                    string      url   = string.Empty;
                    AMMediaType mtype = new AMMediaType();
                    fs.GetCurFile(out url, mtype);
                    if (url == null)
                    {
                        URLDialog ud = new URLDialog();
                        if (ud.ShowDialog() == DialogResult.OK)
                        {
                            fs.Load(ud.URL, null);
                        }
                        ud.Dispose();
                        ud = null;
                    }
                    fs = null;
                }
                else
                {
                    // it wants a filename
                    string      filename = string.Empty;
                    AMMediaType mtype    = new AMMediaType();
                    fs.GetCurFile(out filename, mtype);
                    if (filename == null)
                    {
                        OpenFileDialog ofd = new OpenFileDialog();
                        if (ofd.ShowDialog() == DialogResult.OK)
                        {
                            fs.Load(ofd.FileName, null);
                        }
                        ofd.Dispose();
                        ofd = null;
                    }
                    fs = null;
                }
            }

            // if it's a filewriter, get the filename for it
            IFileSinkFilter fw = filter as IFileSinkFilter;

            if (fw != null)
            {
                string      filename = string.Empty;
                AMMediaType mtype    = new AMMediaType();
                fw.GetCurFile(out filename, mtype);
                if (filename == null)
                {
                    SaveFileDialog sfd = new SaveFileDialog();
                    if (sfd.ShowDialog() == DialogResult.OK)
                    {
                        fw.SetFileName(sfd.FileName, null);
                    }
                }
                fw = null;
            }

            // create and add all DaggerPins for this filter
            SyncPins();
        }