コード例 #1
0
        public override bool RemoveCapability(ICapability capability)
        {
            bool ret = base.RemoveCapability(capability);

            if (ret)
            {
                if (fgm != null)
                {
                    fgm.Stop();
                    FilterGraph.RemoveFromRot(rotID);
                    FilterGraph.RemoveAllFilters(fgm);
                    fgm = null;
                }

                if (fgmEventMonitor != null)
                {
                    fgmEventMonitor.FgmEvent -= new FgmEventMonitor.FgmEventHandler(FgmEvent);
                    fgmEventMonitor.Dispose();
                    fgmEventMonitor = null;
                }

                wmf = null;
            }

            return(ret);
        }
コード例 #2
0
        /// <summary>
        /// Creates and initializes the Fgm, retrieves interfaces from it, starts the monitoring
        /// thread etc. the first time.  Stops it subsequent times.
        /// </summary>
        private void InitializeFgm()
        {
            if (fgm == null)
            {
                fgm   = new FilgraphManagerClass();
                iGB   = (IGraphBuilder)fgm;
                iCGB2 = MDShow.CaptureGraphBuilder2Class.CreateInstance();
                iCGB2.SetFiltergraph(iGB);

                rotID = FilterGraph.AddToRot(iGB);

                // Initialize class that will monitor events on the fgm
                fgmEventMonitor           = new FgmEventMonitor((IMediaEvent)fgm);
                fgmEventMonitor.FgmEvent += new FgmEventMonitor.FgmEventHandler(FgmEvent);
            }
            else
            {
                fgm.Stop();
            }
        }
コード例 #3
0
ファイル: frmWMV.cs プロジェクト: abhishek-kumar/AIGA
        /// <summary>
        /// The callback method once the file is done playing.
        /// 
        /// Important:  This method is called from a non-UI thread.  Due to COM rules, the fgm, 
        /// its interfaces, filters, etc. are not really accessible from this thread.  One solution
        /// is to use this.Invoke in order to get execution back onto the UI thread (example below).
        /// The alternative approach is to have the thread(s) created in the MTA (multithreaded 
        /// apartment).  This is most easily accomplished by changing the STAThreaded attribute in
        /// Form.Main to use MTAThreaded.
        /// 
        /// Parameters are unused but available due to the paradigm
        /// </summary>
        private void FgmEvent(object sender, FgmEventMonitor.FgmEventArgs ea)
        {
            switch (ea.EventCode)
            {
                case 1: // EC_COMPLETE
                    {
                        // If MTAThread set on Form.Main, no need to Invoke
                        // FileFinished();

                        if (InvokeRequired)
                        {
                            // Manipulate all DShow and COM objects from UI thread
                            // Should always take this path during the callback
                            Invoke(new MethodInvoker(FileFinished), null);
                        }
                        else // STA && InvokeRequired
                        {
                            FileFinished();
                        }

                        break;
                    }

                // Besides EC_COMPLETE, these are the only other events I have seen fire

                case 0x0D: // EC_CLOCK_CHANGED
                case 0x0E: // EC_PAUSED
                    break;

                default:
                    {
                        Console.WriteLine("EventCode: {0}, Param1: {1}, Param2: {2}",
                            ea.EventCode, ea.Param1, ea.Param2);
                        break;
                    }
            }
        }
コード例 #4
0
ファイル: frmWMV.cs プロジェクト: abhishek-kumar/AIGA
        /// <summary>
        /// Creates and initializes the Fgm, retrieves interfaces from it, starts the monitoring 
        /// thread etc. the first time.  Stops it subsequent times.
        /// </summary>
        private void InitializeFgm()
        {
            if (fgm == null)
            {
                fgm = new FilgraphManagerClass();
                iGB = (IGraphBuilder)fgm;
                iCGB2 = MDShow.CaptureGraphBuilder2Class.CreateInstance();
                iCGB2.SetFiltergraph(iGB);

                rotID = FilterGraph.AddToRot(iGB);

                // Initialize class that will monitor events on the fgm
                fgmEventMonitor = new FgmEventMonitor((IMediaEvent)fgm);
                fgmEventMonitor.FgmEvent += new FgmEventMonitor.FgmEventHandler(FgmEvent);
            }
            else
            {
                fgm.Stop();
            }
        }
コード例 #5
0
ファイル: frmWMV.cs プロジェクト: abhishek-kumar/AIGA
        public override bool RemoveCapability(ICapability capability)
        {
            bool ret = base.RemoveCapability(capability);

            if (ret)
            {
                if (fgm != null)
                {
                    fgm.Stop();
                    FilterGraph.RemoveFromRot(rotID);
                    FilterGraph.RemoveAllFilters(fgm);
                    fgm = null;
                }

                if (fgmEventMonitor != null)
                {
                    fgmEventMonitor.FgmEvent -= new FgmEventMonitor.FgmEventHandler(FgmEvent);
                    fgmEventMonitor.Dispose();
                    fgmEventMonitor = null;
                }

                wmf = null;
            }

            return ret;
        }