private void ShowAllocatorRequirements(object sender, EventArgs e) { if (connectingPin != null) { IMemInputPin imip = connectingPin.IPin as IMemInputPin; if (imip != null) { try { AllocatorProperties pr = new AllocatorProperties(); int hr = imip.GetAllocatorRequirements(out pr); DsError.ThrowExceptionForHR(hr); if (pr != null) Program.mainform.propform.SetObject(new FieldsToPropertiesProxyTypeDescriptor(pr)); } catch (COMException ex) { Graph.ShowCOMException(ex, "Can't get requirements"); } catch (Exception ex) { MessageBox.Show(ex.Message, "Exception caught in IMemInputPin::GetAllocatorRequirements"); } } } connectingPin = null; }
private void MediaTypeListForm_Load(object sender, EventArgs e) { int count; try { listBox.Items.Add("null (resets to default on some filters)"); listBox.Items.Add(MediaTypeProps.CreateMTProps(new AMMediaType()).ToString()); if (isc.GetNumberOfCapabilities(out count, out size) >= 0) { scc = Marshal.AllocHGlobal(size); for (int i = 0; i < count; i++) { AMMediaType mt; int hr = isc.GetStreamCaps(i, out mt, scc); DsError.ThrowExceptionForHR(hr); string s = MediaTypeProps.CreateMTProps(mt).ToString(); listBox.Items.Add(s); } } } catch (COMException ex) { Graph.ShowCOMException(ex, "Error getting stream capabilities"); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void OnSelChange(object sender, EventArgs e) { try { int i = listBox.SelectedIndex; if (i == 0) { selected_mt = null; } if (i == 1) { selected_mt = new AMMediaType(); } if (i >= 2) { AMMediaType mt; int hr = isc.GetStreamCaps(i - 2, out mt, scc); DsError.ThrowExceptionForHR(hr); selected_mt = mt; } propertyGrid.SelectedObject = selected_mt != null? MediaTypeProps.CreateMTProps(selected_mt) : null; } catch (COMException ex) { Graph.ShowCOMException(ex, "Error trying to GetStreamCaps"); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
public string ChooseSrcFileName() { string ret = null; IFileSourceFilter fsrc = basefilter as IFileSourceFilter; if (fsrc != null) { using (var fd = new OpenFileDialog()) { fd.DefaultExt = "*.*"; if (fd.ShowDialog() == DialogResult.OK) { try { int hr = fsrc.Load(fd.FileName, null); DsError.ThrowExceptionForHR(hr); ret = fd.FileName; } catch (COMException e) { Graph.ShowCOMException(e, "Can't load file " + fd.FileName); } catch (Exception e) { MessageBox.Show(e.Message, "Exception caught while loading file " + fd.FileName); } } else if (Program.mainform.suggestURLs) { using (var rf = new RenderURLForm("Open URL")) { rf.ShowDialog(); if (rf.selectedURL != null) { try { int hr = fsrc.Load(rf.selectedURL, null); DsError.ThrowExceptionForHR(hr); ret = rf.selectedURL; } catch (COMException e) { Graph.ShowCOMException(e, "Can't open " + rf.selectedURL); } catch (Exception e) { MessageBox.Show(e.Message, "Exception caught while loading URL " + rf.selectedURL); } } } //using } }//using } return(ret); }
public string ChooseDstFileName() { string ret = null; IFileSinkFilter fdst = basefilter as IFileSinkFilter; if (fdst != null) { using (var fd = new SaveFileDialog()) { if (fd.ShowDialog() == DialogResult.OK) { try { int hr = fdst.SetFileName(fd.FileName, null); DsError.ThrowExceptionForHR(hr); ret = fd.FileName; } catch (COMException e) { Graph.ShowCOMException(e, "Can't create file " + fd.FileName); } catch (Exception e) { MessageBox.Show(e.Message, "Exception caught while setting output file name " + fd.FileName); } } else if (Program.mainform.suggestURLs) { using (var rf = new RenderURLForm("Open URL")) { rf.ShowDialog(); if (rf.selectedURL != null) { try { int hr = fdst.SetFileName(rf.selectedURL, null); DsError.ThrowExceptionForHR(hr); ret = rf.selectedURL; } catch (COMException e) { Graph.ShowCOMException(e, "Can't set " + rf.selectedURL); } catch (Exception e) { MessageBox.Show(e.Message, "Exception caught while setting URL " + rf.selectedURL); } } } //using rf } }//using fd } return(ret); }
public void Prepare() //filename must be created { if (prepared) { return; } try { string keyname = @"CLSID\" + catguid + @"\Instance\" + guid; using (RegistryKey rk = Registry.ClassesRoot.OpenSubKey(keyname)) { if (rk != null) { byte[] bytes = (byte[])rk.GetValue("FilterData"); if (bytes != null && bytes.Length >= 8) { version = (((((bytes[3] << 8) + bytes[2]) << 8) + bytes[1]) << 8) + bytes[0]; merit = (((((bytes[7] << 8) + bytes[6]) << 8) + bytes[5]) << 8) + bytes[4]; } } } try { FileInfo fi = new FileInfo(filename); if (fi.Exists) { filesize = fi.Length; cr_time = fi.CreationTime; mod_time = fi.LastWriteTime; ver_info = FileVersionInfo.GetVersionInfo(filename); } else { filename += " (file not found)"; } } catch { filename += " (file not found)"; } prepared = true; } catch (COMException e) { Graph.ShowCOMException(e, "Can't get filter info"); return; } catch (Exception e) { MessageBox.Show(e.Message, "Can't get filter info"); return; } }
private void SampleGrabberForm_Load(object sender, EventArgs e) { try { int hr = sampleGrabber.SetCallback(cb, 0); DsError.ThrowExceptionForHR(hr); } catch (COMException ex) { Graph.ShowCOMException(ex, "Can't set callback"); } catch (Exception ex) { MessageBox.Show(ex.Message, "Exception caught while setting callback for samplegrabber"); } }
private void GetStreamCaps(object sender, EventArgs e) { try { if (connectingPin != null) connectingPin.GetStreamCaps(); } catch (COMException ex) { Graph.ShowCOMException(ex, "Error getting stream caps"); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } connectingPin = null; }
private void OnOK(object sender, EventArgs e) { try { int hr = isc.SetFormat(selected_mt); DsError.ThrowExceptionForHR(hr); DialogResult = DialogResult.OK; Close(); } catch (COMException ex) { Graph.ShowCOMException(ex, "Error trying to SetFormat"); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void catcombo_SelectedIndexChanged(object sender, EventArgs e) { try { current_category_filters = GetFiltersOfCategory(catcombo.SelectedItem.ToString()); ShowSearchedFilters(); } catch (COMException ex) { Graph.ShowCOMException(ex, "Can't enumerate filter category"); return; } catch (Exception ex) { MessageBox.Show(ex.Message, "Can't enumerate filter category"); return; } }
private void SaveFilterStateToCodeImpl(bool cpp) { if (rightClickedFilter != null) { try { rightClickedFilter.SaveStateToCode(cpp); } catch (COMException ex) { Graph.ShowCOMException(ex, "Can't get save filter's state"); } catch (Exception ex) { MessageBox.Show(ex.Message, "Exception caught while saving state"); } } rightClickedFilter = null; }
private void SampleGrabberForm_FormClosing(object sender, FormClosingEventArgs e) { try { filter.sampleGrabberForm = null; filter = null; int hr = sampleGrabber.SetCallback(null, 0); DsError.ThrowExceptionForHR(hr); timer.Stop(); sampleGrabber = null; } catch (COMException ex) { Graph.ShowCOMException(ex, "Can't set callback to null"); } catch (Exception ex) { MessageBox.Show(ex.Message, "Exception caught while setting callback for samplegrabber"); } }
private void MatchingFiltersForm_Load(object sender, EventArgs e) { List <Guid> guids = new List <Guid>(); try { if (pin.Connection != null) { AMMediaType mt = new AMMediaType(); pin.IPin.ConnectionMediaType(mt); guids.Add(mt.majorType); guids.Add(mt.subType); DsUtils.FreeAMMediaType(mt); } else { IEnumMediaTypes mtenum; if (pin.IPin.EnumMediaTypes(out mtenum) >= 0) { AMMediaType[] mts = new AMMediaType[1]; IntPtr fetched = Marshal.AllocHGlobal(4); while (mtenum.Next(1, mts, fetched) == 0) { guids.Add(mts[0].majorType); guids.Add(mts[0].subType); DsUtils.FreeAMMediaType(mts[0]); } Marshal.FreeHGlobal(fetched); } } IFilterMapper2 fm = (IFilterMapper2) new FilterMapper2(); IEnumMoniker emon, emon_rend; //non-renderers, renderers int hr = 0; List <FilterProps> fplist = new List <FilterProps>(); if (pin.Direction == PinDirection.Output) { hr = fm.EnumMatchingFilters(out emon, 0, true, Merit.None, true, guids.Count / 2, guids.ToArray(), null, null, false, false, 0, null, null, null); DsError.ThrowExceptionForHR(hr); hr = fm.EnumMatchingFilters(out emon_rend, 0, true, Merit.None, true, guids.Count / 2, guids.ToArray(), null, null, true, false, 0, null, null, null); DsError.ThrowExceptionForHR(hr); fplist.AddRange(Filterz.GetFiltersFromEnum(emon, Guid.Empty)); fplist.AddRange(Filterz.GetFiltersFromEnum(emon_rend, Guid.Empty)); } else { hr = fm.EnumMatchingFilters(out emon, 0, true, Merit.None, false, 0, null, null, null, false, true, guids.Count / 2, guids.ToArray(), null, null); DsError.ThrowExceptionForHR(hr); hr = fm.EnumMatchingFilters(out emon_rend, 0, true, Merit.None, false, 0, null, null, null, true, true, guids.Count / 2, guids.ToArray(), null, null); DsError.ThrowExceptionForHR(hr); fplist.AddRange(Filterz.GetFiltersFromEnum(emon, Guid.Empty)); fplist.AddRange(Filterz.GetFiltersFromEnum(emon_rend, Guid.Empty)); } //Filterz.BuildFilterTree(emon, treeView, Guid.Empty); Filterz.FillFilterTree(treeView, fplist); } catch (COMException ex) { Graph.ShowCOMException(ex, "Can't enumerate matching filters"); } catch (Exception ex) { MessageBox.Show(ex.Message, "Exception caught while enumerating matching filters"); } }
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); } }
public void RefreshCategories() { object old_selection = catcombo.SelectedItem; //clear values catcombo.Items.Clear(); catnames.Clear(); catguids.Clear(); all_filters = null; try { //fill catnames dictionary (guid_string => category_name) ICreateDevEnum devenum = new CreateDevEnum() as ICreateDevEnum; IEnumMoniker emon; int hr = devenum.CreateClassEnumerator(FilterCategory.ActiveMovieCategories, out emon, 0); if (0 == hr) { IMoniker[] mon = new IMoniker[1]; while (0 == emon.Next(1, mon, IntPtr.Zero)) { string name; mon[0].GetDisplayName(null, null, out name); string sg = name.Substring(name.Length - 38, 38).ToUpperInvariant(); object bagObj; Guid propertyBagId = typeof(IPropertyBag).GUID; mon[0].BindToStorage(null, null, ref propertyBagId, out bagObj); IPropertyBag bag = (IPropertyBag)bagObj; object nameObj; bag.Read("FriendlyName", out nameObj, null); name = nameObj as string; if (!catnames.ContainsKey(sg)) { catnames.Add(sg, name); } Marshal.ReleaseComObject(bagObj); Marshal.ReleaseComObject(mon[0]); } } } catch (COMException e) { Graph.ShowCOMException(e, "Can't enumerate filter categories"); return; } catch (Exception e) { MessageBox.Show(e.Message, "Can't enumerate filter categories"); return; } Type ty = typeof(Application); Addcat(FilterCategory.ActiveMovieCategories, "ActiveMovieCategories"); Addcat(FilterCategory.AMKSAudio, "KS Audio"); Addcat(FilterCategory.AMKSCapture, "KS Capture"); Addcat(FilterCategory.AMKSCrossbar, "KS Crossbar"); Addcat(FilterCategory.AMKSDataCompressor, "KS Data Compressor"); Addcat(FilterCategory.AMKSRender, "KS Render"); Addcat(FilterCategory.AMKSSplitter, "KS Splitter"); Addcat(FilterCategory.AMKSTVAudio, "KS TV Audio"); Addcat(FilterCategory.AMKSTVTuner, "KS TV Tuner"); Addcat(FilterCategory.AMKSVBICodec, "KS VBI Codec"); Addcat(FilterCategory.AMKSVideo, "KS Video"); Addcat(FilterCategory.AudioCompressorCategory, "Audio Compressors"); Addcat(FilterCategory.AudioEffects1Category, "Audio Effects 1"); Addcat(FilterCategory.AudioEffects2Category, "Audio Effects 2"); Addcat(FilterCategory.AudioInputDevice, "Audio Input Devices"); Addcat(FilterCategory.AudioRendererCategory, "Audio Renderers"); Addcat(FilterCategory.BDANetworkProvidersCategory, "BDA Network Providers"); Addcat(FilterCategory.BDAReceiverComponentsCategory, "BDA Receiver Components"); Addcat(FilterCategory.BDARenderingFiltersCategory, "BDA Rendering Filters"); Addcat(FilterCategory.BDASourceFiltersCategory, "BDA Source Filters"); Addcat(FilterCategory.BDATransportInformationRenderersCategory, "BDA Transport Information Renderers"); Addcat(FilterCategory.CPCAFiltersCategory, "CPCA Filters"); Addcat(FilterCategory.DeviceControlCategory, "Device Controls"); Addcat(FilterCategory.DMOFilterCategory, "DMO Filters"); Addcat(FilterCategory.KSAudioDevice, "KS Audio Devices"); Addcat(FilterCategory.KSCommunicationsTransform, "KS Communications Transforms"); Addcat(FilterCategory.KSDataDecompressor, "KS Data Decompressors"); Addcat(FilterCategory.KSDataTransform, "KS Data Transforms"); Addcat(FilterCategory.KSInterfaceTransform, "KS Interface Transforms"); Addcat(FilterCategory.KSMixer, "KS Mixers"); Addcat(FilterCategory.LegacyAmFilterCategory, "DirectShow Filters"); // Addcat(FilterCategory.LTMMVideoProcessors, "LTMM Video Processors"); Addcat(FilterCategory.MediaEncoderCategory, "Media Encoders"); Addcat(FilterCategory.MediaMultiplexerCategory, "Media Multiplexers"); Addcat(FilterCategory.MidiRendererCategory, "Midi Renderers"); Addcat(FilterCategory.TransmitCategory, "Transmits"); Addcat(FilterCategory.VideoCompressorCategory, "Video Compressors"); Addcat(FilterCategory.VideoEffects1Category, "Video Effects 1"); Addcat(FilterCategory.VideoEffects2Category, "Video Effects 2"); Addcat(FilterCategory.VideoInputDevice, "Video Input Devices"); Addcat(FilterCategory.WDMStreamingEncoderDevices, "WDM Streaming Encoder Devices"); Addcat(FilterCategory.WDMStreamingMultiplexerDevices, "WDM Streaming Multiplexer Devices"); foreach (KeyValuePair <string, Guid> p in dmo_cats) { Addcat(p.Value, p.Key); } //fill combo box and remember guids foreach (KeyValuePair <string, string> p in catnames) { Guid guid = new Guid(p.Key); if (!catguids.ContainsKey(p.Value)) { catguids.Add(p.Value, guid); } catcombo.Items.Add(p.Value); } RegistryChecker rch = new RegistryChecker(); RegistryChecker.CalcDays(ty); catcombo.SelectedItem = old_selection ?? catnames[Graph.GuidToString(FilterCategory.LegacyAmFilterCategory)]; }