// Token: 0x06000378 RID: 888 RVA: 0x000146E4 File Offset: 0x000128E4 public VfwCompressorPropertyPage(string name__1, IAMVfwCompressDialogs compressDialogs) { this.vfwCompressDialogs = null; this.Name = name__1; this.SupportsPersisting = true; this.vfwCompressDialogs = compressDialogs; }
// Find an video compression filter IAMVfwCompressDialogs GetCompressionFilter() { DsDevice [] capDevices; IAMVfwCompressDialogs ifcd = null; int x; string s = ""; // Get the collection of video devices capDevices = DsDevice.GetDevicesOfCat(FilterCategory.VideoCompressorCategory); if (capDevices.Length == 0) { throw new Exception("No video compressors found!"); } for (x = 0; x < capDevices.Length; x++) { DsDevice dev = capDevices[x]; dev.Mon.GetDisplayName(null, null, out s); if (dev.Name == "Intel Indeo® Video 4.5") //"Microsoft Video 1") { break; } } if (x >= capDevices.Length) { throw new Exception("can't find the video 1 filter"); } ifcd = Marshal.BindToMoniker(s) as IAMVfwCompressDialogs; return(ifcd); }
protected override void Dispose(bool disposing) { base.Dispose(disposing); if (vfwCompressDialogs != null) Marshal.ReleaseComObject(vfwCompressDialogs); vfwCompressDialogs = null; }
protected override void Dispose(bool disposing) { base.Dispose(disposing); if (vfwCompressDialogs != null) { Marshal.ReleaseComObject(vfwCompressDialogs); } vfwCompressDialogs = null; }
/// <summary> /// Displays a property page for a filter /// </summary> /// <param name="dev">The filter for which to display a property page</param> public static void DisplayPropertyPage(IBaseFilter dev, IntPtr hwndOwner) { Trace.WriteLine("Tangra.DirectShowVideoBase: Showing properties page on managed thread " + Thread.CurrentThread.ManagedThreadId); //Get the ISpecifyPropertyPages for the filter ISpecifyPropertyPages pProp = dev as ISpecifyPropertyPages; int hr = 0; if (pProp == null) { //If the filter doesn't implement ISpecifyPropertyPages, try displaying IAMVfwCompressDialogs instead! IAMVfwCompressDialogs compressDialog = dev as IAMVfwCompressDialogs; if (compressDialog != null) { try { compressDialog.ShowDialog(VfwCompressDialogs.Config, IntPtr.Zero); } catch (Exception ex) { Trace.WriteLine(ex.ToString()); } } return; } //Get the name of the filter from the FilterInfo struct FilterInfo filterInfo; hr = dev.QueryFilterInfo(out filterInfo); DsError.ThrowExceptionForHR(hr); // Get the propertypages from the property bag DsCAUUID caGUID; hr = pProp.GetPages(out caGUID); DsError.ThrowExceptionForHR(hr); // Create and display the OlePropertyFrame object oDevice = (object)dev; hr = OleCreatePropertyFrame(hwndOwner, 0, 0, filterInfo.achName, 1, ref oDevice, caGUID.cElems, caGUID.pElems, 0, 0, IntPtr.Zero); DsError.ThrowExceptionForHR(hr); // Release COM objects Marshal.FreeCoTaskMem(caGUID.pElems); Marshal.ReleaseComObject(pProp); if (filterInfo.pGraph != null) { Marshal.ReleaseComObject(filterInfo.pGraph); } }
public static void ShowDevicePropertyPages(IBaseFilter filter, IntPtr hWndOwner) { int hResult = 0; ISpecifyPropertyPages propPages = filter as ISpecifyPropertyPages; if (propPages != null) { try { // get the name of the filter from the FilterInfo struct hResult = filter.QueryFilterInfo(out var filterInfo); DsError.ThrowExceptionForHR(hResult); // get the propertypages from the property bag hResult = propPages.GetPages(out var caGUID); DsError.ThrowExceptionForHR(hResult); // create and display the OlePropertyFrame object[] oDevice = new[] { (object)filter }; hResult = Ole.OleAut32.OleCreatePropertyFrame(hWndOwner, 0, 0, filterInfo.achName, 1, oDevice, caGUID.cElems, caGUID.ToGuidArray(), 0, 0, 0); DsError.ThrowExceptionForHR(hResult); // release COM objects if (caGUID.pElems != IntPtr.Zero) { Marshal.FreeCoTaskMem(caGUID.pElems); } if (filterInfo.pGraph != null) { Marshal.ReleaseComObject(filterInfo.pGraph); } } finally { Marshal.ReleaseComObject(propPages); } } else { // if the filter doesn't implement ISpecifyPropertyPages, try displaying IAMVfwCompressDialogs instead IAMVfwCompressDialogs compressDialog = filter as IAMVfwCompressDialogs; if (compressDialog != null) { hResult = compressDialog.ShowDialog(VfwCompressDialogs.Config, IntPtr.Zero); DsError.ThrowExceptionForHR(hResult); } return; } }
/// <summary> /// Displays a property page for a filter /// </summary> /// <param name="dev">The filter for which to display a property page</param> private void DisplayPropertyPage(IBaseFilter dev) { //Get the ISpecifyPropertyPages for the filter ISpecifyPropertyPages pProp = dev as ISpecifyPropertyPages; int hr = 0; if (pProp == null) { //If the filter doesn't implement ISpecifyPropertyPages, try displaying IAMVfwCompressDialogs instead! IAMVfwCompressDialogs compressDialog = dev as IAMVfwCompressDialogs; if (compressDialog != null) { hr = compressDialog.ShowDialog(VfwCompressDialogs.Config, IntPtr.Zero); DsError.ThrowExceptionForHR(hr); } else { MessageBox.Show("Item has no property page", "No Property Page", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } return; } //Get the name of the filter from the FilterInfo struct FilterInfo filterInfo; hr = dev.QueryFilterInfo(out filterInfo); DsError.ThrowExceptionForHR(hr); // Get the propertypages from the property bag DsCAUUID caGUID; hr = pProp.GetPages(out caGUID); DsError.ThrowExceptionForHR(hr); //Create and display the OlePropertyFrame object oDevice = (object)dev; hr = OleCreatePropertyFrame(this.Handle, 0, 0, filterInfo.achName, 1, ref oDevice, caGUID.cElems, caGUID.pElems, 0, 0, IntPtr.Zero); DsError.ThrowExceptionForHR(hr); Marshal.ReleaseComObject(oDevice); if (filterInfo.pGraph != null) { Marshal.ReleaseComObject(filterInfo.pGraph); } // Release COM objects Marshal.FreeCoTaskMem(caGUID.pElems); }
public void DoTests() { // Get an audio device m_ivcd = GetCompressionFilter(); try { TestDialog(); TestState(); TestSendMessage(); } finally { Marshal.ReleaseComObject(m_ivcd); } }
internal static void _DisplayPropertyPage(object filter_or_pin, IntPtr hwndOwner) { if (filter_or_pin != null) { DirectShowLib.ISpecifyPropertyPages o = filter_or_pin as DirectShowLib.ISpecifyPropertyPages; if (o == null) { IAMVfwCompressDialogs dialogs = filter_or_pin as IAMVfwCompressDialogs; if (dialogs != null) { /* DsError.ThrowExceptionForHR(dialogs.ShowDialog(VfwCompressDialogs.Config, IntPtr.Zero));*/ } } else { DsCAUUID scauuid; string lpszCaption = string.Empty; if (filter_or_pin is IBaseFilter) { FilterInfo info; IBaseFilter filter = filter_or_pin as IBaseFilter; // DsError.ThrowExceptionForHR(filter.QueryFilterInfo(out info)); // lpszCaption = info.achName; // if (info.pGraph != null) // { // Marshal.ReleaseComObject(info.pGraph); // } } else if (filter_or_pin is IPin) { PinInfo info2; IPin pin = filter_or_pin as IPin; /* DsError.ThrowExceptionForHR(pin.QueryPinInfo(out info2));*/ /* lpszCaption = info2.name;*/ } DsError.ThrowExceptionForHR(o.GetPages(out scauuid)); object ppUnk = filter_or_pin; DsError.ThrowExceptionForHR(NativeMethodes.OleCreatePropertyFrame(hwndOwner, 0, 0, lpszCaption, 1, ref ppUnk, scauuid.cElems, scauuid.pElems, 0, 0, IntPtr.Zero)); Marshal.FreeCoTaskMem(scauuid.pElems); Marshal.ReleaseComObject(o); } } }
// ------------------ Public Methods -------------------- /// <summary> Populate the collection by looking for commonly implemented property pages. </summary> protected void addFromGraph( ICaptureGraphBuilder2 graphBuilder, IBaseFilter videoDeviceFilter, IBaseFilter audioDeviceFilter, IBaseFilter videoCompressorFilter, IBaseFilter audioCompressorFilter, SourceCollection videoSources, SourceCollection audioSources) { object filter = null; DsGuid cat; DsGuid med; Guid iid; int hr; Trace.Assert(graphBuilder != null); // 1. the video capture filter addIfSupported(videoDeviceFilter, "Video Capture Device"); // 2. the video capture pin cat = new DsGuid(PinCategory.Capture); med = new DsGuid(MediaType.Interleaved); iid = typeof(IAMStreamConfig).GUID; hr = graphBuilder.FindInterface( cat, med, videoDeviceFilter, iid, out filter); if (hr != 0) { med = MediaType.Video; hr = graphBuilder.FindInterface( cat, med, videoDeviceFilter, iid, out filter); if (hr != 0) { filter = null; } } addIfSupported(filter, "Video Capture Pin"); // 3. the video preview pin cat = PinCategory.Preview; med = MediaType.Interleaved; iid = typeof(IAMStreamConfig).GUID; hr = graphBuilder.FindInterface( cat, med, videoDeviceFilter, iid, out filter); if (hr != 0) { med = MediaType.Video; hr = graphBuilder.FindInterface( cat, med, videoDeviceFilter, iid, out filter); if (hr != 0) { filter = null; } } addIfSupported(filter, "Video Preview Pin"); // 4. the video crossbar(s) ArrayList crossbars = new ArrayList(); int num = 1; for (int c = 0; c < videoSources.Count; c++) { CrossbarSource s = videoSources[c] as CrossbarSource; if (s != null) { if (crossbars.IndexOf(s.Crossbar) < 0) { crossbars.Add(s.Crossbar); if (addIfSupported(s.Crossbar, "Video Crossbar " + (num == 1 ? "" : num.ToString()))) { num++; } } } } crossbars.Clear(); // 5. the video compressor addIfSupported(videoCompressorFilter, "Video Compressor"); // 6. the video TV tuner cat = new DsGuid(PinCategory.Capture); med = new DsGuid(MediaType.Interleaved); iid = typeof(IAMTVTuner).GUID; hr = graphBuilder.FindInterface( cat, med, videoDeviceFilter, iid, out filter); if (hr != 0) { med = MediaType.Video; hr = graphBuilder.FindInterface( cat, med, videoDeviceFilter, iid, out filter); if (hr != 0) { filter = null; } } addIfSupported(filter, "TV Tuner"); // 7. the video compressor (VFW) IAMVfwCompressDialogs compressDialog = videoCompressorFilter as IAMVfwCompressDialogs; if (compressDialog != null) { VfwCompressorPropertyPage page = new VfwCompressorPropertyPage("Video Compressor", compressDialog); InnerList.Add(page); } // 8. the audio capture filter addIfSupported(audioDeviceFilter, "Audio Capture Device"); // 9. the audio capture pin cat = new DsGuid(PinCategory.Capture); med = new DsGuid(MediaType.Audio); iid = typeof(IAMStreamConfig).GUID; hr = graphBuilder.FindInterface( cat, med, audioDeviceFilter, iid, out filter); if (hr != 0) { filter = null; } addIfSupported(filter, "Audio Capture Pin"); // 9. the audio preview pin cat = new DsGuid(PinCategory.Preview); med = new DsGuid(MediaType.Audio); iid = typeof(IAMStreamConfig).GUID; hr = graphBuilder.FindInterface( cat, med, audioDeviceFilter, iid, out filter); if (hr != 0) { filter = null; } addIfSupported(filter, "Audio Preview Pin"); // 10. the audio crossbar(s) num = 1; for (int c = 0; c < audioSources.Count; c++) { CrossbarSource s = audioSources[c] as CrossbarSource; if (s != null) { if (crossbars.IndexOf(s.Crossbar) < 0) { crossbars.Add(s.Crossbar); if (addIfSupported(s.Crossbar, "Audio Crossbar " + (num == 1 ? "" : num.ToString()))) { num++; } } } } crossbars.Clear(); // 11. the audio compressor addIfSupported(audioCompressorFilter, "Audio Compressor"); }
public VfwCompressorPropertyPage(string name, IAMVfwCompressDialogs compressDialogs) { base.Name = name; base.SupportsPersisting = true; this.vfwCompressDialogs = compressDialogs; }
public void DisplayPropertyPage() { if (theDevice != null) { Marshal.ReleaseComObject(theDevice); theDevice = null; } //Create the filter for the selected video input device string devicepath = _filter.Name; // cd.VideoSource; //comboBox1.SelectedItem.ToString(); theDevice = CreateFilter(FilterCategory.VideoInputDevice, devicepath); IBaseFilter dev = theDevice; //Get the ISpecifyPropertyPages for the filter ISpecifyPropertyPages pProp = dev as ISpecifyPropertyPages; int hr = 0; if (pProp == null) { //If the filter doesn't implement ISpecifyPropertyPages, try displaying IAMVfwCompressDialogs instead! IAMVfwCompressDialogs compressDialog = dev as IAMVfwCompressDialogs; if (compressDialog != null) { hr = compressDialog.ShowDialog(VfwCompressDialogs.Config, IntPtr.Zero); DsError.ThrowExceptionForHR(hr); } return; } //Get the name of the filter from the FilterInfo struct FilterInfo filterInfo; hr = dev.QueryFilterInfo(out filterInfo); DsError.ThrowExceptionForHR(hr); // Get the propertypages from the property bag DsCAUUID caGUID; hr = pProp.GetPages(out caGUID); DsError.ThrowExceptionForHR(hr); // Check for property pages on the output pin IPin pPin = DsFindPin.ByDirection(dev, PinDirection.Output, 0); ISpecifyPropertyPages pProp2 = pPin as ISpecifyPropertyPages; if (pProp2 != null) { DsCAUUID caGUID2; hr = pProp2.GetPages(out caGUID2); DsError.ThrowExceptionForHR(hr); if (caGUID2.cElems > 0) { int soGuid = Marshal.SizeOf(typeof(Guid)); // Create a new buffer to hold all the GUIDs IntPtr p1 = Marshal.AllocCoTaskMem((caGUID.cElems + caGUID2.cElems) * soGuid); // Copy over the pages from the Filter for (int x = 0; x < caGUID.cElems * soGuid; x++) { Marshal.WriteByte(p1, x, Marshal.ReadByte(caGUID.pElems, x)); } // Add the pages from the pin for (int x = 0; x < caGUID2.cElems * soGuid; x++) { Marshal.WriteByte(p1, x + (caGUID.cElems * soGuid), Marshal.ReadByte(caGUID2.pElems, x)); } // Release the old memory Marshal.FreeCoTaskMem(caGUID.pElems); Marshal.FreeCoTaskMem(caGUID2.pElems); // Reset caGUID to include both caGUID.pElems = p1; caGUID.cElems += caGUID2.cElems; } } // Create and display the OlePropertyFrame try { object oDevice = (object)dev; hr = OleCreatePropertyFrame(_parent.Handle, 10, 10, filterInfo.achName, 1, ref oDevice, caGUID.cElems, caGUID.pElems, 0, 0, IntPtr.Zero); } catch (Exception E) { // DsError.ThrowExceptionForHR(hr); } // Release COM objects Marshal.FreeCoTaskMem(caGUID.pElems); Marshal.ReleaseComObject(pProp); if (filterInfo.pGraph != null) { Marshal.ReleaseComObject(filterInfo.pGraph); } }
// Token: 0x0600034F RID: 847 RVA: 0x00013C68 File Offset: 0x00011E68 protected void addFromGraph(ICaptureGraphBuilder2 graphBuilder, IBaseFilter videoDeviceFilter, IBaseFilter audioDeviceFilter, IBaseFilter videoCompressorFilter, IBaseFilter audioCompressorFilter, SourceCollection videoSources, SourceCollection audioSources) { object obj = null; Trace.Assert(graphBuilder != null); this.addIfSupported(videoDeviceFilter, "Video Capture Device"); Guid guid = PinCategory.Capture; Guid guid2 = MediaType.Interleaved; Guid guid3 = typeof(IAMStreamConfig).GUID; int num = graphBuilder.FindInterface(ref guid, ref guid2, videoDeviceFilter, ref guid3, out obj); if (num != 0) { guid2 = MediaType.Video; num = graphBuilder.FindInterface(ref guid, ref guid2, videoDeviceFilter, ref guid3, out obj); if (num != 0) { obj = null; } } this.addIfSupported(RuntimeHelpers.GetObjectValue(obj), "Video Capture Pin"); guid = PinCategory.Preview; guid2 = MediaType.Interleaved; guid3 = typeof(IAMStreamConfig).GUID; num = graphBuilder.FindInterface(ref guid, ref guid2, videoDeviceFilter, ref guid3, out obj); if (num != 0) { guid2 = MediaType.Video; num = graphBuilder.FindInterface(ref guid, ref guid2, videoDeviceFilter, ref guid3, out obj); if (num != 0) { obj = null; } } this.addIfSupported(RuntimeHelpers.GetObjectValue(obj), "Video Preview Pin"); ArrayList arrayList = new ArrayList(); int num2 = 1; int num3 = 0; checked { int num4 = videoSources.Count - 1; for (int i = num3; i <= num4; i++) { CrossbarSource crossbarSource = videoSources[i] as CrossbarSource; if (crossbarSource != null && arrayList.IndexOf(crossbarSource.Crossbar) < 0) { arrayList.Add(crossbarSource.Crossbar); if (this.addIfSupported(crossbarSource.Crossbar, "Video Crossbar " + ((num2 == 1) ? "" : num2.ToString()))) { num2++; } } } arrayList.Clear(); this.addIfSupported(videoCompressorFilter, "Video Compressor"); guid = PinCategory.Capture; guid2 = MediaType.Interleaved; guid3 = typeof(IAMTVTuner).GUID; num = graphBuilder.FindInterface(ref guid, ref guid2, videoDeviceFilter, ref guid3, out obj); if (num != 0) { guid2 = MediaType.Video; num = graphBuilder.FindInterface(ref guid, ref guid2, videoDeviceFilter, ref guid3, out obj); if (num != 0) { obj = null; } } this.addIfSupported(RuntimeHelpers.GetObjectValue(obj), "TV Tuner"); IAMVfwCompressDialogs iamvfwCompressDialogs = videoCompressorFilter as IAMVfwCompressDialogs; if (iamvfwCompressDialogs != null) { VfwCompressorPropertyPage value = new VfwCompressorPropertyPage("Video Compressor", iamvfwCompressDialogs); this.InnerList.Add(value); } this.addIfSupported(audioDeviceFilter, "Audio Capture Device"); guid = PinCategory.Capture; guid2 = MediaType.Audio; guid3 = typeof(IAMStreamConfig).GUID; num = graphBuilder.FindInterface(ref guid, ref guid2, audioDeviceFilter, ref guid3, out obj); if (num != 0) { obj = null; } this.addIfSupported(RuntimeHelpers.GetObjectValue(obj), "Audio Capture Pin"); guid = PinCategory.Preview; guid2 = MediaType.Audio; guid3 = typeof(IAMStreamConfig).GUID; num = graphBuilder.FindInterface(ref guid, ref guid2, audioDeviceFilter, ref guid3, out obj); if (num != 0) { obj = null; } this.addIfSupported(RuntimeHelpers.GetObjectValue(obj), "Audio Preview Pin"); num2 = 1; int num5 = 0; int num6 = audioSources.Count - 1; for (int j = num5; j <= num6; j++) { CrossbarSource crossbarSource2 = audioSources[j] as CrossbarSource; if (crossbarSource2 != null && arrayList.IndexOf(crossbarSource2.Crossbar) < 0) { arrayList.Add(crossbarSource2.Crossbar); if (this.addIfSupported(crossbarSource2.Crossbar, "Audio Crossbar " + ((num2 == 1) ? "" : num2.ToString()))) { num2++; } } } arrayList.Clear(); this.addIfSupported(audioCompressorFilter, "Audio Compressor"); } }
internal static void _DisplayPropertyPage(object filter_or_pin, IntPtr hwndOwner) { if (filter_or_pin == null) { return; } //Get the ISpecifyPropertyPages for the filter ISpecifyPropertyPages pProp = filter_or_pin as ISpecifyPropertyPages; int hr = 0; if (pProp == null) { //If the filter doesn't implement ISpecifyPropertyPages, try displaying IAMVfwCompressDialogs instead! IAMVfwCompressDialogs compressDialog = filter_or_pin as IAMVfwCompressDialogs; if (compressDialog != null) { hr = compressDialog.ShowDialog(VfwCompressDialogs.Config, IntPtr.Zero); DsError.ThrowExceptionForHR(hr); } return; } string caption = string.Empty; if (filter_or_pin is IBaseFilter) { //Get the name of the filter from the FilterInfo struct IBaseFilter as_filter = filter_or_pin as IBaseFilter; FilterInfo filterInfo; hr = as_filter.QueryFilterInfo(out filterInfo); DsError.ThrowExceptionForHR(hr); caption = filterInfo.achName; if (filterInfo.pGraph != null) { Marshal.ReleaseComObject(filterInfo.pGraph); } } else if (filter_or_pin is IPin) { //Get the name of the filter from the FilterInfo struct IPin as_pin = filter_or_pin as IPin; PinInfo pinInfo; hr = as_pin.QueryPinInfo(out pinInfo); DsError.ThrowExceptionForHR(hr); caption = pinInfo.name; } // Get the propertypages from the property bag DsCAUUID caGUID; hr = pProp.GetPages(out caGUID); DsError.ThrowExceptionForHR(hr); // Create and display the OlePropertyFrame object oDevice = (object)filter_or_pin; hr = NativeMethodes.OleCreatePropertyFrame(hwndOwner, 0, 0, caption, 1, ref oDevice, caGUID.cElems, caGUID.pElems, 0, 0, IntPtr.Zero); DsError.ThrowExceptionForHR(hr); // Release COM objects Marshal.FreeCoTaskMem(caGUID.pElems); Marshal.ReleaseComObject(pProp); }
private void OnRButtonDown(Point eLocation) { Filter filter = graph.FilterInPoint(mousepos); if (filter != null) { Pin pin = filter.PinInPoint(mousepos); if (pin != null) { movingStart = mousepos; connectingPin = pin; } else //filter right click { rightClickedFilter = filter; ContextMenu menu = new ContextMenu(); if (FilterGraphTools.HasPropertyPages(filter.BaseFilter)) menu.MenuItems.Add("Property page", ShowPropertyPage); IAMVfwCompressDialogs vfw = filter.BaseFilter as IAMVfwCompressDialogs; if (vfw != null) { if (vfw.ShowDialog(VfwCompressDialogs.QueryConfig, Handle) == 0) menu.MenuItems.Add("VfW compressor: Config", VfWConfig); if (vfw.ShowDialog(VfwCompressDialogs.QueryAbout, Handle) == 0) menu.MenuItems.Add("VfW compressor: About", VfWAbout); } if ((filter.BaseFilter as ISampleGrabber) != null) { menu.MenuItems.Add("Set media type", SetSGMediaType); menu.MenuItems.Add("Watch grabbed samples", WatchSampleGrabber); } menu.MenuItems.Add("Scan interfaces", ScanInterfaces); if (filter.filterProps.DisplayName.Length > 0) { menu.MenuItems.Add("Add to favorites", AddToFavorites); menu.MenuItems.Add("Find this filter in the list", FindFilterInList); } if ((filter.BaseFilter as IPersistStream) != null) { menu.MenuItems.Add("Save state to C++ code", SaveFilterStateToCode); menu.MenuItems.Add("Save state to C# code", SaveFilterStateToCodeCS); } menu.Show(this, eLocation); } } else //out of filter right click { ContextMenu menu = new ContextMenu(); menu.MenuItems.Add("Render file...", RenderFile); menu.MenuItems.Add("Add source filter...", AddSourceFilter); menu.MenuItems.Add("Load graph...", LoadGraph); if (savedFileName != null) menu.MenuItems.Add("Save graph", SaveGraph); menu.MenuItems.Add("Save graph as...", SaveGraphAs); menu.MenuItems.Add("See event log...", ShowEventLog); menu.MenuItems.Add("Arrange filters", delegate { graph.LayoutFilters(); graph.RecalcPaths(); Invalidate(); }); menu.MenuItems.Add("Refresh graph", delegate { graph.ReloadGraph(); Invalidate(); }); menu.Show(this, eLocation); } }
/// <summary> /// Constructor /// </summary> /// <param name="name">The name compress dialog.</param> /// <param name="compressDialogs"></param> public VfwCompressorPropertyPage(string name, IAMVfwCompressDialogs compressDialogs) { Name = name; SupportsPersisting = true; this.vfwCompressDialogs = compressDialogs; }
/// <summary> /// Displays a property page for a filter /// </summary> /// <param name="parentHandle">An <see cref="IntPtr"/> with the handle for the parent window of the dialog.</param> /// <param name="dev">The <see cref="IBaseFilter"/> for which to display a property page.</param> public static void DisplayPropertyPage(IntPtr parentHandle, IBaseFilter dev) { // Get the ISpecifyPropertyPages for the filter ISpecifyPropertyPages properties = dev as ISpecifyPropertyPages; int hr = 0; if (properties == null) { // If the filter doesn't implement ISpecifyPropertyPages, try displaying IAMVfwCompressDialogs instead! IAMVfwCompressDialogs compressDialog = dev as IAMVfwCompressDialogs; if (compressDialog != null) { hr = compressDialog.ShowDialog(VfwCompressDialogs.Config, IntPtr.Zero); DsError.ThrowExceptionForHR(hr); } return; } // Get the name of the filter from the FilterInfo struct FilterInfo filterInfo; hr = dev.QueryFilterInfo(out filterInfo); DsError.ThrowExceptionForHR(hr); // Get the propertypages from the property bag DsCAUUID captureGUID; hr = properties.GetPages(out captureGUID); DsError.ThrowExceptionForHR(hr); // Check for property pages on the output pin IPin pin = DsFindPin.ByDirection(dev, PinDirection.Output, 0); ISpecifyPropertyPages properties2 = pin as ISpecifyPropertyPages; if (properties2 != null) { DsCAUUID captureGUID2; hr = properties2.GetPages(out captureGUID2); DsError.ThrowExceptionForHR(hr); if (captureGUID2.cElems > 0) { int guidSize = Marshal.SizeOf(typeof(Guid)); // Create a new buffer to hold all the GUIDs IntPtr p1 = Marshal.AllocCoTaskMem((captureGUID.cElems + captureGUID2.cElems) * guidSize); // Copy over the pages from the Filter for (int x = 0; x < captureGUID.cElems * guidSize; x++) { Marshal.WriteByte(p1, x, Marshal.ReadByte(captureGUID.pElems, x)); } // Add the pages from the pin for (int x = 0; x < captureGUID2.cElems * guidSize; x++) { Marshal.WriteByte(p1, x + (captureGUID.cElems * guidSize), Marshal.ReadByte(captureGUID2.pElems, x)); } // Release the old memory Marshal.FreeCoTaskMem(captureGUID.pElems); Marshal.FreeCoTaskMem(captureGUID2.pElems); // Reset caGUID to include both captureGUID.pElems = p1; captureGUID.cElems += captureGUID2.cElems; } } // Create and display the OlePropertyFrame object device = (object)dev; hr = Oleaut32.OleCreatePropertyFrame(parentHandle, 0, 0, filterInfo.achName, 1, ref device, captureGUID.cElems, captureGUID.pElems, 0, 0, IntPtr.Zero); DsError.ThrowExceptionForHR(hr); // Release COM objects Marshal.FreeCoTaskMem(captureGUID.pElems); Marshal.ReleaseComObject(properties); if (filterInfo.pGraph != null) { Marshal.ReleaseComObject(filterInfo.pGraph); } }
protected void addFromGraph(ICaptureGraphBuilder2 graphBuilder, IBaseFilter videoDeviceFilter, IBaseFilter audioDeviceFilter, IBaseFilter videoCompressorFilter, IBaseFilter audioCompressorFilter, SourceCollection videoSources, SourceCollection audioSources) { object ppint = null; Trace.Assert(graphBuilder != null); this.addIfSupported(videoDeviceFilter, "Video Capture Device"); Guid capture = PinCategory.Capture; Guid interleaved = MediaType.Interleaved; Guid gUID = typeof(IAMStreamConfig).GUID; if (graphBuilder.FindInterface(ref capture, ref interleaved, videoDeviceFilter, ref gUID, out ppint) != 0) { interleaved = MediaType.Video; if (graphBuilder.FindInterface(ref capture, ref interleaved, videoDeviceFilter, ref gUID, out ppint) != 0) { ppint = null; } } this.addIfSupported(ppint, "Video Capture Pin"); capture = PinCategory.Preview; interleaved = MediaType.Interleaved; gUID = typeof(IAMStreamConfig).GUID; if (graphBuilder.FindInterface(ref capture, ref interleaved, videoDeviceFilter, ref gUID, out ppint) != 0) { interleaved = MediaType.Video; if (graphBuilder.FindInterface(ref capture, ref interleaved, videoDeviceFilter, ref gUID, out ppint) != 0) { ppint = null; } } this.addIfSupported(ppint, "Video Preview Pin"); ArrayList list = new ArrayList(); int num = 1; for (int i = 0; i < videoSources.Count; i++) { CrossbarSource source = videoSources[i] as CrossbarSource; if ((source != null) && (list.IndexOf(source.Crossbar) < 0)) { list.Add(source.Crossbar); if (this.addIfSupported(source.Crossbar, "Video Crossbar " + ((num == 1) ? "" : num.ToString()))) { num++; } } } list.Clear(); this.addIfSupported(videoCompressorFilter, "Video Compressor"); capture = PinCategory.Capture; interleaved = MediaType.Interleaved; gUID = typeof(IAMTVTuner).GUID; if (graphBuilder.FindInterface(ref capture, ref interleaved, videoDeviceFilter, ref gUID, out ppint) != 0) { interleaved = MediaType.Video; if (graphBuilder.FindInterface(ref capture, ref interleaved, videoDeviceFilter, ref gUID, out ppint) != 0) { ppint = null; } } this.addIfSupported(ppint, "TV Tuner"); IAMVfwCompressDialogs compressDialogs = videoCompressorFilter as IAMVfwCompressDialogs; if (compressDialogs != null) { VfwCompressorPropertyPage page = new VfwCompressorPropertyPage("Video Compressor", compressDialogs); base.InnerList.Add(page); } this.addIfSupported(audioDeviceFilter, "Audio Capture Device"); capture = PinCategory.Capture; interleaved = MediaType.Audio; gUID = typeof(IAMStreamConfig).GUID; if (graphBuilder.FindInterface(ref capture, ref interleaved, audioDeviceFilter, ref gUID, out ppint) != 0) { ppint = null; } this.addIfSupported(ppint, "Audio Capture Pin"); capture = PinCategory.Preview; interleaved = MediaType.Audio; gUID = typeof(IAMStreamConfig).GUID; if (graphBuilder.FindInterface(ref capture, ref interleaved, audioDeviceFilter, ref gUID, out ppint) != 0) { ppint = null; } this.addIfSupported(ppint, "Audio Preview Pin"); num = 1; for (int j = 0; j < audioSources.Count; j++) { CrossbarSource source2 = audioSources[j] as CrossbarSource; if ((source2 != null) && (list.IndexOf(source2.Crossbar) < 0)) { list.Add(source2.Crossbar); if (this.addIfSupported(source2.Crossbar, "Audio Crossbar " + ((num == 1) ? "" : num.ToString()))) { num++; } } } list.Clear(); this.addIfSupported(audioCompressorFilter, "Audio Compressor"); }