예제 #1
0
        /// <summary>
        /// 视频属性页设置
        /// 原生方式
        /// </summary>
        public void changeCameraSetting(IntPtr Handle)
        {
            DsCAUUID cauuid = new DsCAUUID();

            try
            {
                specifyPropertyPages = theDevice as ISpecifyPropertyPages;
                if (specifyPropertyPages == null)
                {
                    MessageBox.Show("请先打开视频设备!");
                    return;
                }
                //返回filter所支持的属性页的CLSID
                int hr = specifyPropertyPages.GetPages(out cauuid);
                if (hr != 0)
                {
                    Marshal.ThrowExceptionForHR(hr);
                }

                object o = specifyPropertyPages;
                //获取属性页
                hr = OleCreatePropertyFrame(Handle, 30, 30, null, 1,
                                            ref o, cauuid.cElems, cauuid.pElems, 0, 0, IntPtr.Zero);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Unable display property page. Please submit a bug report.\n\n" + ex.Message + "\n\n" + ex.ToString());
            }
        }
예제 #2
0
        protected bool addIfSupported(object o, string name)
        {
            ISpecifyPropertyPages specifyPropertyPages = null;
            DsCAUUID pPages = new DsCAUUID();
            bool     flag   = false;

            try
            {
                specifyPropertyPages = o as ISpecifyPropertyPages;
                if ((specifyPropertyPages != null) && ((specifyPropertyPages.GetPages(out pPages) != 0) || (pPages.cElems <= 0)))
                {
                    specifyPropertyPages = null;
                }
            }
            finally
            {
                if (pPages.pElems != IntPtr.Zero)
                {
                    Marshal.FreeCoTaskMem(pPages.pElems);
                }
            }
            if (specifyPropertyPages != null)
            {
                DirectShowPropertyPage page = new DirectShowPropertyPage(name, specifyPropertyPages);
                base.InnerList.Add(page);
                flag = true;
            }
            return(flag);
        }
예제 #3
0
        // Token: 0x06000350 RID: 848 RVA: 0x00013FF8 File Offset: 0x000121F8
        protected bool addIfSupported(object o, string name)
        {
            ISpecifyPropertyPages specifyPropertyPages = null;
            DsCAUUID dsCAUUID = default(DsCAUUID);
            bool     result   = false;

            try
            {
                specifyPropertyPages = (o as ISpecifyPropertyPages);
                if (specifyPropertyPages != null)
                {
                    int pages = specifyPropertyPages.GetPages(ref dsCAUUID);
                    if (pages != 0 || dsCAUUID.cElems <= 0)
                    {
                        specifyPropertyPages = null;
                    }
                }
            }
            finally
            {
                if (dsCAUUID.pElems != IntPtr.Zero)
                {
                    Marshal.FreeCoTaskMem(dsCAUUID.pElems);
                }
            }
            if (specifyPropertyPages != null)
            {
                DirectShowPropertyPage value = new DirectShowPropertyPage(name, specifyPropertyPages);
                this.InnerList.Add(value);
                result = true;
            }
            return(result);
        }
예제 #4
0
        private void ShowPropPages(object obj)
        {
            ISpecifyPropertyPages specPropPages = null;

            try
            {
                specPropPages = obj as ISpecifyPropertyPages;
                if (null == specPropPages)
                {
                    MessageBox.Show("Property pages not available");
                    return;
                }

                DsCAUUID cauuid;
                int      hr = specPropPages.GetPages(out cauuid);
                DsError.ThrowExceptionForHR(hr);

                if (hr == 0 && cauuid.cElems > 0)
                {
                    // show property pages
                    hr = WinAPI.OleCreatePropertyFrame(this.Handle,
                                                       30, 30, null, 1,
                                                       ref obj, cauuid.cElems,
                                                       cauuid.pElems, 0, 0, IntPtr.Zero);

                    Marshal.FreeCoTaskMem(cauuid.pElems);
                }
            }
            catch (COMException ex)
            {
                MessageBox.Show(ex.ToString());
            }

            //do not release interfaces obtained with a cast (as), the primary interface is also released
        }
 /// <summary> Release unmanaged resources </summary>
 public new void Dispose()
 {
     if (specifyPropertyPages != null)
     {
         DirectShowUtil.ReleaseComObject(specifyPropertyPages);
     }
     specifyPropertyPages = null;
 }
예제 #6
0
 /// <summary> Release unmanaged resources </summary>
 public void Dispose()
 {
     if (this.specifyPropertyPages != null)
     {
         Marshal.ReleaseComObject(this.specifyPropertyPages);
     }
     this.specifyPropertyPages = null;
 }
 /// <summary> Release unmanaged resources </summary>
 public new void Dispose()
 {
     if (specifyPropertyPages != null)
     {
         Marshal.ReleaseComObject(specifyPropertyPages);
     }
     specifyPropertyPages = null;
 }
 /// <summary> Release unmanaged resources </summary>
 public void Dispose()
 {
     if (this.specifyPropertyPages != null)
     {
         Marshal.ReleaseComObject(this.specifyPropertyPages);
     }
     this.specifyPropertyPages = null;
 }
예제 #9
0
        /// <summary> Release unmanaged resources </summary>
        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);

            if (specifyPropertyPages != null)
            {
                Marshal.ReleaseComObject(specifyPropertyPages);
            }
            specifyPropertyPages = null;
        }
예제 #10
0
        /// <summary>
        /// Display property window for the video capture device providing its configuration
        /// capabilities.
        /// </summary>
        ///
        /// <param name="parentWindow">Handle of parent window.</param>
        ///
        /// <remarks><para><note>If you pass parent window's handle to this method, then the
        /// displayed property page will become modal window and none of the controls from the
        /// parent window will be accessible. In order to make it modeless it is required
        /// to pass <see cref="IntPtr.Zero"/> as parent window's handle.
        /// </note></para>
        /// </remarks>
        ///
        /// <exception cref="NotSupportedException">The video source does not support configuration property page.</exception>
        ///
        public void DisplayPropertyPage(IntPtr parentWindow)
        {
            // check source
            if ((deviceMoniker == null) || (deviceMoniker == string.Empty))
            {
                throw new ArgumentException("Video source is not specified");
            }

            lock (this)
            {
                if (IsRunning)
                {
                    // pass the request to backgroud thread if video source is running
                    parentWindowForPropertyPage = parentWindow;
                    needToDisplayPropertyPage   = true;
                    return;
                }

                object tempSourceObject = null;

                // create source device's object
                try
                {
                    tempSourceObject = FilterInfo.CreateFilter(deviceMoniker);
                }
                catch
                {
                    throw new ApplicationException("Failed creating device object for moniker.");
                }

                if (!(tempSourceObject is ISpecifyPropertyPages))
                {
                    throw new NotSupportedException("The video source does not support configuration property page.");
                }

                // retrieve ISpecifyPropertyPages interface of the device
                ISpecifyPropertyPages pPropPages = (ISpecifyPropertyPages)tempSourceObject;

                // get property pages from the property bag
                CAUUID caGUID;
                pPropPages.GetPages(out caGUID);

                // get filter info
                FilterInfo filterInfo = new FilterInfo(deviceMoniker);

                // create and display the OlePropertyFrame form
                Win32.OleCreatePropertyFrame(parentWindow, 0, 0, filterInfo.Name, 1, ref tempSourceObject, caGUID.cElems, caGUID.pElems, 0, 0, IntPtr.Zero);

                // release COM objects
                Marshal.FreeCoTaskMem(caGUID.pElems);
                Marshal.ReleaseComObject(tempSourceObject);
            }
        }
예제 #11
0
        public static bool ShowCapPinDialog(ICaptureGraphBuilder2 bld, IBaseFilter flt, IntPtr hwnd)
        {
            int    hr;
            object comObj = null;
            ISpecifyPropertyPages spec = null;
            DsCAUUID cauuid            = new DsCAUUID();

            try
            {
                Guid cat  = PinCategory.Capture;
                Guid type = MediaType.Interleaved;
                Guid iid  = typeof(IAMStreamConfig).GUID;
                hr = bld.FindInterface(ref cat, ref type, flt, ref iid, out comObj);
                if (hr != 0)
                {
                    type = MediaType.Video;
                    hr   = bld.FindInterface(ref cat, ref type, flt, ref iid, out comObj);
                    if (hr != 0)
                    {
                        return(false);
                    }
                }
                spec = comObj as ISpecifyPropertyPages;
                if (spec == null)
                {
                    return(false);
                }

                hr = spec.GetPages(out cauuid);
                hr = OleCreatePropertyFrame(hwnd, 30, 30, null, 1,
                                            ref comObj, cauuid.cElems, cauuid.pElems, 0, 0, IntPtr.Zero);
                return(true);
            }
            catch (Exception ee)
            {
                Trace.WriteLine("!Ds.NET: ShowCapPinDialog " + ee.Message);
                return(false);
            }
            finally
            {
                if (cauuid.pElems != IntPtr.Zero)
                {
                    Marshal.FreeCoTaskMem(cauuid.pElems);
                }

                spec = null;
                if (comObj != null)
                {
                    Marshal.ReleaseComObject(comObj);
                }
                comObj = null;
            }
        }
예제 #12
0
        // Token: 0x060002F4 RID: 756 RVA: 0x00012B14 File Offset: 0x00010D14
        public static bool ShowTunerPinDialog(ICaptureGraphBuilder2 bld, IBaseFilter flt, IntPtr hwnd)
        {
            object   obj      = null;
            DsCAUUID dsCAUUID = default(DsCAUUID);
            bool     result;

            try
            {
                Guid capture = PinCategory.Capture;
                Guid guid    = MediaType.Interleaved;
                Guid guid2   = typeof(IAMTVTuner).GUID;
                int  num     = bld.FindInterface(ref capture, ref guid, flt, ref guid2, out obj);
                if (num != 0)
                {
                    guid = MediaType.Video;
                    num  = bld.FindInterface(ref capture, ref guid, flt, ref guid2, out obj);
                    if (num != 0)
                    {
                        return(false);
                    }
                }
                ISpecifyPropertyPages specifyPropertyPages = obj as ISpecifyPropertyPages;
                if (specifyPropertyPages == null)
                {
                    result = false;
                }
                else
                {
                    num    = specifyPropertyPages.GetPages(ref dsCAUUID);
                    num    = DsUtils.OleCreatePropertyFrame(hwnd, 30, 30, null, 1, ref obj, dsCAUUID.cElems, dsCAUUID.pElems, 0, 0, IntPtr.Zero);
                    result = true;
                }
            }
            catch (Exception ex)
            {
                Trace.WriteLine("!Ds.NET: ShowCapPinDialog " + ex.Message);
                result = false;
            }
            finally
            {
                if (dsCAUUID.pElems != IntPtr.Zero)
                {
                    Marshal.FreeCoTaskMem(dsCAUUID.pElems);
                }
                if (obj != null)
                {
                    Marshal.ReleaseComObject(RuntimeHelpers.GetObjectValue(obj));
                }
                obj = null;
            }
            return(result);
        }
예제 #13
0
        /// <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);
            }
        }
예제 #14
0
        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;
            }
        }
예제 #15
0
 private void DisplayPropertyPage(IntPtr parentWindow, object sourceObject)
 {
     try
     {
         ISpecifyPropertyPages specifyPropertyPages = (ISpecifyPropertyPages)sourceObject;
         specifyPropertyPages.GetPages(out CAUUID pPages);
         FilterInfo filterInfo = new FilterInfo(deviceMoniker);
         Win32.OleCreatePropertyFrame(parentWindow, 0, 0, filterInfo.Name, 1, ref sourceObject, pPages.cElems, pPages.pElems, 0, 0, IntPtr.Zero);
         Marshal.FreeCoTaskMem(pPages.pElems);
     }
     catch
     {
     }
 }
예제 #16
0
        /// <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);
        }
예제 #17
0
        public static bool ShowCapPinDialog(ICaptureGraphBuilder2 bld, IBaseFilter flt, IntPtr hwnd)
        {
            object ppint = null;
            ISpecifyPropertyPages pages = null;
            bool     flag;
            DsCAUUID pPages = new DsCAUUID();

            try
            {
                Guid capture     = PinCategory.Capture;
                Guid interleaved = MediaType.Interleaved;
                Guid gUID        = typeof(IAMStreamConfig).GUID;
                if (bld.FindInterface(ref capture, ref interleaved, flt, ref gUID, out ppint) != 0)
                {
                    interleaved = MediaType.Video;
                    if (bld.FindInterface(ref capture, ref interleaved, flt, ref gUID, out ppint) != 0)
                    {
                        return(false);
                    }
                }
                pages = ppint as ISpecifyPropertyPages;
                if (pages == null)
                {
                    return(false);
                }
                int num = pages.GetPages(out pPages);
                num  = OleCreatePropertyFrame(hwnd, 30, 30, null, 1, ref ppint, pPages.cElems, pPages.pElems, 0, 0, IntPtr.Zero);
                flag = true;
            }
            catch (Exception exception)
            {
                Trace.WriteLine("!Ds.NET: ShowCapPinDialog " + exception.Message);
                flag = false;
            }
            finally
            {
                if (pPages.pElems != IntPtr.Zero)
                {
                    Marshal.FreeCoTaskMem(pPages.pElems);
                }
                pages = null;
                if (ppint != null)
                {
                    Marshal.ReleaseComObject(ppint);
                }
                ppint = null;
            }
            return(flag);
        }
예제 #18
0
        public void TestGetPages()
        {
            int        hr = 0;
            FilterInfo filterInfo;
            DsCAUUID   pages = new DsCAUUID();

            try
            {
                // Just to retrieve the name of the filter
                hr = this.filter.QueryFilterInfo(out filterInfo);
                DsError.ThrowExceptionForHR(hr);

                // An exception is thrown if the cast is imposible
                ISpecifyPropertyPages propertyPages = (ISpecifyPropertyPages)this.filter;

                // Query PerperyPages Guid
                hr = propertyPages.GetPages(out pages);
                DsError.ThrowExceptionForHR(hr);

                object obj = (object)this.filter;

                // Display the property window
                hr = OleCreatePropertyFrame(
                    IntPtr.Zero,
                    0,
                    0,
                    filterInfo.achName,
                    1,
                    ref obj,
                    pages.cElems,
                    pages.pElems,
                    0,
                    0,
                    IntPtr.Zero
                    );
                DsError.ThrowExceptionForHR(hr);
            }
            finally
            {
                // pElems memory must be freed
                if (pages.pElems != IntPtr.Zero)
                {
                    Marshal.FreeCoTaskMem(pages.pElems);
                }
            }
        }
예제 #19
0
 public PropertyPageHelper(DsDevice dev)
 {
     try
     {
         object source;
         var    id = typeof(IBaseFilter).GUID;
         dev.Mon.BindToObject(null, null, ref id, out source);
         if (source != null)
         {
             var filter = (IBaseFilter)source;
             m_specifyPropertyPages = filter as ISpecifyPropertyPages;
         }
     }
     catch
     {
         MessageBox.Show(NO_PROPERTY_PAGE_FOUND);
     }
 }
 public PropertyPageHelper(DsDevice dev)
 {
     try
     {
         object source;
         var id = typeof(IBaseFilter).GUID;
         dev.Mon.BindToObject(null, null, ref id, out source);
         if (source != null)
         {
             var filter = (IBaseFilter)source;
             m_specifyPropertyPages = filter as ISpecifyPropertyPages;
         }
     }
     catch
     {
         MessageBox.Show(NO_PROPERTY_PAGE_FOUND);
     }
 }
예제 #21
0
        private void pbImage_DoubleClick(object sender, EventArgs e)
        {
            if (active_config == null)
            {
                return;
            }

            ISpecifyPropertyPages property_pages = (ISpecifyPropertyPages)active_config.Filter;
            DsCAUUID pages_uuid;

            property_pages.GetPages(out pages_uuid);
            OleHelper.OleCreatePropertyFrame(
                IntPtr.Zero,
                0, 0,
                "",
                1, new object[] { active_config.Filter },
                pages_uuid.cElems, pages_uuid.pElems,
                0, 0, IntPtr.Zero);
        }
 /// <summary> Constructor </summary>
 /// <param name="dev"> Shows the PropertyPages of a specific DsDevice </param>
 public DirectShowPropertyPage(DsDevice dev)
 {
     try
     {
         object l_Source = null;
         Guid   l_Iid    = typeof(IBaseFilter).GUID;
         dev.Mon.BindToObject(null, null, ref l_Iid, out l_Source);
         if (l_Source != null)
         {
             Name = dev.Name;
             IBaseFilter filter = (IBaseFilter)l_Source;
             SupportsPersisting        = false;
             this.specifyPropertyPages = filter as ISpecifyPropertyPages;
         }
     }
     catch
     {
         MessageBox.Show("This filter has no property page!");
     }
 }
 /// <summary> Constructor </summary>
 /// <param name="dev"> Shows the PropertyPages of a specific DsDevice </param>
 public DirectShowPropertyPage(DsDevice dev)
 {
   try
   {
     object l_Source = null;
     Guid l_Iid = typeof (IBaseFilter).GUID;
     dev.Mon.BindToObject(null, null, ref l_Iid, out l_Source);
     if (l_Source != null)
     {
       Name = dev.Name;
       IBaseFilter filter = (IBaseFilter)l_Source;
       SupportsPersisting = false;
       this.specifyPropertyPages = filter as ISpecifyPropertyPages;
     }
   }
   catch
   {
     MessageBox.Show("This filter has no property page!");
   }
 }
예제 #24
0
        /// <summary>
        /// User has clicked on a pin properties menu item
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void tmi_Click(object sender, EventArgs e)
        {
            // if this pin implements ISpecifyPropertyPages, show that instead
            PropertiesDialog pd;
            IPin             pin = null;
            string           pinname;

            // get the DaggerPin
            DSOutputPin opin = (sender as ToolStripMenuItem).Tag as DSOutputPin;

            if (opin != null)
            {
                // it's an output pin
                pin     = opin._pin;
                pinname = opin.Name;
            }
            else
            {
                // it's an input pin
                pin     = ((sender as ToolStripMenuItem).Tag as DSInputPin)._pin;
                pinname = ((sender as ToolStripMenuItem).Tag as DSInputPin).Name;
            }

            ISpecifyPropertyPages proppage = pin as ISpecifyPropertyPages;
            bool displayed = false;

            if (proppage != null)
            {
                // display the pin's property pages
                displayed = DirectShowLib.Utils.FilterGraphTools.ShowPinFilterPropertyPage(pin, this.TopLevelControl.Handle, pinname);
            }

            // if ShowPinFilterPropertyPage failed, or there's no ISpecifyPropertyPages, show the default pin info
            if (!displayed)
            {
                pd = new PropertiesDialog(pinname, pin);
                pd.ShowDialog();
                pd.Dispose();
                pd = null;
            }
        }
예제 #25
0
        /// <summary>
        ///  Returns the object as an ISpecificPropertyPage
        ///  if the object supports the ISpecificPropertyPage
        ///  interface and has at least one property page.
        /// </summary>
        protected bool addIfSupported(object o, string name)
        {
            ISpecifyPropertyPages specifyPropertyPages = null;
            DsCAUUID cauuid   = new DsCAUUID();
            bool     wasAdded = false;

            // Determine if the object supports the interface
            // and has at least 1 property page
            try
            {
                specifyPropertyPages = o as ISpecifyPropertyPages;
                if (specifyPropertyPages != null)
                {
                    int hr = specifyPropertyPages.GetPages(out cauuid);
                    if ((hr != 0) || (cauuid.cElems <= 0))
                    {
                        specifyPropertyPages = null;
                    }
                }
            }
            finally
            {
                if (cauuid.pElems != IntPtr.Zero)
                {
                    Marshal.FreeCoTaskMem(cauuid.pElems);
                }
            }

            // Add the page to the internal collection
            if (specifyPropertyPages != null)
            {
                DirectShowPropertyPage p = new DirectShowPropertyPage(name, specifyPropertyPages);
                InnerList.Add(p);
                wasAdded = true;
            }
            return(wasAdded);
        }
예제 #26
0
        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);
        }
예제 #27
0
        /// <summary> build the capture graph for grabber. </summary>
        private void SetupGraph(DsDevice dev, int iWidth, int iHeight, short iBPP, Control hControl)
        {
            int hr;

            ISampleGrabber  sampGrabber = null;
            IBaseFilter     capFilter   = null;
            IPin            pCaptureOut = null;
            IPin            pSampleIn   = null;
            IPin            pRenderIn   = null;
            IAMVideoProcAmp vpa         = null;

            // Get the graphbuilder object
            m_FilterGraph = new FilterGraph() as IFilterGraph2;

            try
            {
#if DEBUG
                m_rot = new DsROTEntry(m_FilterGraph);
#endif
                // add the video input device
                hr = m_FilterGraph.AddSourceFilterForMoniker(dev.Mon, null, dev.Name, out capFilter);
                DsError.ThrowExceptionForHR(hr);

                // Find the still pin
                m_pinStill = DsFindPin.ByCategory(capFilter, PinCategory.Still, 0);

                // Didn't find one.  Is there a preview pin?
                if (m_pinStill == null)
                {
                    m_pinStill = DsFindPin.ByCategory(capFilter, PinCategory.Preview, 0);
                }

                //test
                ISpecifyPropertyPages pProp = capFilter as ISpecifyPropertyPages;

                DsCAUUID caGUID;
                hr = pProp.GetPages(out caGUID);
                DsError.ThrowExceptionForHR(hr);

                // Still haven't found one.  Need to put a splitter in so we have
                // one stream to capture the bitmap from, and one to display.  Ok, we
                // don't *have* to do it that way, but we are going to anyway.
                if (m_pinStill == null)
                {
                    IPin pRaw   = null;
                    IPin pSmart = null;

                    // There is no still pin
                    m_VidControl = null;

                    // Add a splitter
                    IBaseFilter iSmartTee = (IBaseFilter) new SmartTee();

                    try
                    {
                        hr = m_FilterGraph.AddFilter(iSmartTee, "SmartTee");
                        DsError.ThrowExceptionForHR(hr);

                        // Find the find the capture pin from the video device and the
                        // input pin for the splitter, and connnect them
                        pRaw   = DsFindPin.ByCategory(capFilter, PinCategory.Capture, 0);
                        pSmart = DsFindPin.ByDirection(iSmartTee, PinDirection.Input, 0);

                        hr = m_FilterGraph.Connect(pRaw, pSmart);
                        DsError.ThrowExceptionForHR(hr);

                        // Now set the capture and still pins (from the splitter)
                        m_pinStill  = DsFindPin.ByName(iSmartTee, "Preview");
                        pCaptureOut = DsFindPin.ByName(iSmartTee, "Capture");

                        // If any of the default config items are set, perform the config
                        // on the actual video device (rather than the splitter)
                        if (iHeight + iWidth + iBPP > 0)
                        {
                            SetConfigParms(pRaw, iWidth, iHeight, iBPP);
                        }
                    }
                    finally
                    {
                        if (pRaw != null)
                        {
                            Marshal.ReleaseComObject(pRaw);
                        }
                        if (pRaw != pSmart)
                        {
                            Marshal.ReleaseComObject(pSmart);
                        }
                        if (pRaw != iSmartTee)
                        {
                            Marshal.ReleaseComObject(iSmartTee);
                        }
                    }
                }
                else
                {
                    // Get a control pointer (used in Click())
                    m_VidControl = capFilter as IAMVideoControl;

                    pCaptureOut = DsFindPin.ByCategory(capFilter, PinCategory.Capture, 0);

                    // If any of the default config items are set
                    if (iHeight + iWidth + iBPP > 0)
                    {
                        SetConfigParms(m_pinStill, iWidth, iHeight, iBPP);
                    }
                }

                // Get the SampleGrabber interface
                sampGrabber = new SampleGrabber() as ISampleGrabber;

                // Configure the sample grabber
                IBaseFilter baseGrabFlt = sampGrabber as IBaseFilter;
                ConfigureSampleGrabber(sampGrabber);
                pSampleIn = DsFindPin.ByDirection(baseGrabFlt, PinDirection.Input, 0);

                // Get the default video renderer
                IBaseFilter pRenderer = new VideoRendererDefault() as IBaseFilter;
                hr = m_FilterGraph.AddFilter(pRenderer, "Renderer");
                DsError.ThrowExceptionForHR(hr);

                pRenderIn = DsFindPin.ByDirection(pRenderer, PinDirection.Input, 0);

                // Add the sample grabber to the graph
                hr = m_FilterGraph.AddFilter(baseGrabFlt, "Ds.NET Grabber");
                DsError.ThrowExceptionForHR(hr);

                if (m_VidControl == null)
                {
                    // Connect the Still pin to the sample grabber
                    hr = m_FilterGraph.Connect(m_pinStill, pSampleIn);
                    DsError.ThrowExceptionForHR(hr);

                    // Connect the capture pin to the renderer
                    hr = m_FilterGraph.Connect(pCaptureOut, pRenderIn);
                    DsError.ThrowExceptionForHR(hr);
                }
                else
                {
                    // Connect the capture pin to the renderer
                    hr = m_FilterGraph.Connect(pCaptureOut, pRenderIn);
                    DsError.ThrowExceptionForHR(hr);

                    // Connect the Still pin to the sample grabber
                    hr = m_FilterGraph.Connect(m_pinStill, pSampleIn);
                    DsError.ThrowExceptionForHR(hr);
                }
                // Learn the video properties
                SaveSizeInfo(sampGrabber);
                ConfigVideoWindow(hControl);

                // Start the graph
                IMediaControl mediaCtrl = m_FilterGraph as IMediaControl;
                hr = mediaCtrl.Run();
                DsError.ThrowExceptionForHR(hr);
            }
            finally
            {
                if (vpa != null)
                {
                    Marshal.ReleaseComObject(vpa);
                    vpa = null;
                }
                if (sampGrabber != null)
                {
                    Marshal.ReleaseComObject(sampGrabber);
                    sampGrabber = null;
                }
                if (pCaptureOut != null)
                {
                    Marshal.ReleaseComObject(pCaptureOut);
                    pCaptureOut = null;
                }
                if (pRenderIn != null)
                {
                    Marshal.ReleaseComObject(pRenderIn);
                    pRenderIn = null;
                }
                if (pSampleIn != null)
                {
                    Marshal.ReleaseComObject(pSampleIn);
                    pSampleIn = null;
                }
            }
        }
예제 #28
0
        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);
            }
        }
예제 #29
0
 public PropertyPage(ISpecifyPropertyPages iSPP, string name)
 {
     this.iSPP = iSPP;
     this.name = name;
 }
예제 #30
0
		/// <summary> Release unmanaged resources </summary>
		public new void Dispose()
		{
			if ( specifyPropertyPages != null )
				Marshal.ReleaseComObject( specifyPropertyPages ); specifyPropertyPages = null;
		}
예제 #31
0
		// ---------------- Constructors --------------------

		/// <summary> Constructor </summary>
		public DirectShowPropertyPage(string name, ISpecifyPropertyPages specifyPropertyPages)
		{
			Name = name;
			SupportsPersisting = false;
			this.specifyPropertyPages = specifyPropertyPages;
		}
예제 #32
0
        /// <summary>
        /// Occurs when this command is clicked
        /// </summary>
        public override void OnClick()
        {
            try
            {
                //search for the weatherLayer first
                ILayer layer = null;
                RSSWeatherLayerClass RSSLayer = null;

                if (m_pHookHelper.FocusMap.LayerCount == 0)
                {
                    return;
                }

                IEnumLayer layers = m_pHookHelper.FocusMap.get_Layers(null, false);
                layers.Reset();
                layer = layers.Next();
                while (layer != null)
                {
                    if (layer is RSSWeatherLayerClass)
                    {
                        RSSLayer = (RSSWeatherLayerClass)layer;
                        break;
                    }
                    layer = layers.Next();
                }

                //In case that the weather layer wasn't found,just return
                if (null == RSSLayer)
                {
                    return;
                }


                //Launch the layer's properties
                Type   typ;
                object obj;
                Guid[] g;

                // METHOD 1: Instantiating a COM object and displaying its property pages
                // ONLY WORKS ON TRUE COM OBJECTS!  .NET objects that have rolled their own
                // ISpecifyPropertyPages implementation will error out when you try to cast
                // the instantiated object to your own ISpecifyPropertyPages implementation.

                // Get the typeinfo for the ActiveX common dialog control
                typ = Type.GetTypeFromProgID("MSComDlg.CommonDialog");

                // Create an instance of the control.  We pass it to the property frame function
                // so the property pages have an object from which to get current settings and apply
                // new settings.
                obj = Activator.CreateInstance(typ);
                // This handy function calls IPersistStreamInit->New on COM objects to initialize them
                ActiveXMessageFormatter.InitStreamedObject(obj);

                // Get the property pages for the control using the direct CAUUID method
                // This only works for true COM objects and I demonstrate it here only
                // to show how it is done.  Use the static method
                // PropertyPage.GetPagesForType() method for real-world use.
                ISpecifyPropertyPages pag = (ISpecifyPropertyPages)obj;
                CAUUID cau = new CAUUID(0);
                pag.GetPages(ref cau);
                g = cau.GetPages();

                // Instantiating a .NET object and displaying its property pages
                // WORKS ON ALL OBJECTS, .NET or COM

                // Create an instance of the .NET control, MyUserControl
                typ = Type.GetTypeFromProgID("RSSWeatherLayer.PropertySheet");

                // Retrieve the pages for the control
                g = PropertyPage.GetPagesForType(typ);

                // Create an instance of the control that we can give to the property pages
                obj = Activator.CreateInstance(typ);

                //add the RSS layer to the property-sheet control
                ((PropertySheet)obj).RSSWatherLayer = RSSLayer;

                // Display the OLE Property page for the control
                object[] items = new object[] { obj };

                PropertyPage.CreatePropertyFrame(IntPtr.Zero, 500, 500, "RSS Layer properties", items, g);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Trace.WriteLine(ex.Message);
            }
        }
예제 #33
0
        /// <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);
            }
        }
예제 #34
0
        // ---------------- Constructors --------------------

        /// <summary> Constructor </summary>
        public DirectShowPropertyPage(string name, ISpecifyPropertyPages specifyPropertyPages)
        {
            Name = name;
            SupportsPersisting        = false;
            this.specifyPropertyPages = specifyPropertyPages;
        }
 public PropertyPageHelper(IBaseFilter filter)
 {
     m_specifyPropertyPages = filter as ISpecifyPropertyPages;
 }
 /// <summary> Release unmanaged resources </summary>
 public new void Dispose()
 {
   if (specifyPropertyPages != null)
   {
     DirectShowUtil.ReleaseComObject(specifyPropertyPages);
   }
   specifyPropertyPages = null;
 }
 /// <summary> Constructor </summary>
 /// <param name="filter"> Shows the PropertyPages of the specific IBaseFilter</param>
 public DirectShowPropertyPage(IBaseFilter filter)
 {
   Name = filter.ToString();
   SupportsPersisting = false;
   this.specifyPropertyPages = filter as ISpecifyPropertyPages;
 }
 public void Dispose()
 {
     m_specifyPropertyPages = null;
 }
 public PropertyPage(ISpecifyPropertyPages iSPP, string name)
 {
     this.iSPP = iSPP;
     this.name = name;
 }
예제 #40
0
 public void Dispose()
 {
     m_specifyPropertyPages = null;
 }