当前位置: 首页>>代码示例>>C#>>正文


C# IFilterGraph2.AddFilter方法代码示例

本文整理汇总了C#中IFilterGraph2.AddFilter方法的典型用法代码示例。如果您正苦于以下问题:C# IFilterGraph2.AddFilter方法的具体用法?C# IFilterGraph2.AddFilter怎么用?C# IFilterGraph2.AddFilter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IFilterGraph2的用法示例。


在下文中一共展示了IFilterGraph2.AddFilter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: BuildGraph

        private void BuildGraph(string fileName)
        {
            int hr = 0;

             try
             {
                 graphBuilder = (IFilterGraph2)new FilterGraph();
                 mediaControl = (IMediaControl)graphBuilder;

                 mediaSeeking = (IMediaSeeking)graphBuilder;
                 mediaPosition = (IMediaPosition)graphBuilder;

                 vmr9 = (IBaseFilter)new VideoMixingRenderer9();

                 ConfigureVMR9InWindowlessMode();

                 hr = graphBuilder.AddFilter(vmr9, "Video Mixing Renderer 9");
                 DsError.ThrowExceptionForHR(hr);

                 hr = graphBuilder.RenderFile(fileName, null);
                 DsError.ThrowExceptionForHR(hr);
             }
             catch (Exception e)
             {
                 CloseInterfaces();
                 MessageBox.Show("An error occured during the graph building : \r\n\r\n" + e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
        }
开发者ID:andrewjswan,项目名称:mvcentral,代码行数:28,代码来源:framegrabber.cs

示例2: SetupGraph

        // Build the capture graph for grabber and renderer.</summary>
        // (Control to show video in, Filename to play)
        private void SetupGraph(Control hWin, string FileName)
        {
            int hr;

            m_FilterGraph = new FilterGraph() as IFilterGraph2;

            ICaptureGraphBuilder2 icgb2 = new CaptureGraphBuilder2() as ICaptureGraphBuilder2;

            try
            {
                hr = icgb2.SetFiltergraph(m_FilterGraph);
                DsError.ThrowExceptionForHR(hr);

                IBaseFilter sourceFilter = null;
                hr = m_FilterGraph.AddSourceFilter(FileName, FileName, out sourceFilter);
                DsError.ThrowExceptionForHR( hr );

                // Get the SampleGrabber interface
                m_sampGrabber = (ISampleGrabber) new SampleGrabber();
                IBaseFilter baseGrabFlt = (IBaseFilter)	m_sampGrabber;

                // Configure the Sample Grabber
                ConfigureSampleGrabber(m_sampGrabber);

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

                // Connect the pieces together, use the default renderer
                hr = icgb2.RenderStream(null, null, sourceFilter, baseGrabFlt, null);
                DsError.ThrowExceptionForHR( hr );

                // Configure the Video Window
                IVideoWindow videoWindow = m_FilterGraph as IVideoWindow;
                ConfigureVideoWindow(videoWindow, hWin);

                // Grab some other interfaces
                m_mediaEvent = m_FilterGraph as IMediaEvent;
                m_mediaCtrl = m_FilterGraph as IMediaControl;
            }
            finally
            {
                if (icgb2 != null)
                {
                    Marshal.ReleaseComObject(icgb2);
                    icgb2 = null;
                }
            }
        }
开发者ID:devdnhee,项目名称:DMA-project,代码行数:51,代码来源:Capture.cs

示例3: SetupGraph

        /// <summary> build the capture graph for grabber. </summary>
        private void SetupGraph(DsDevice dev, int iFrameRate, int iWidth, int iHeight)
        {
            int hr;

            ISampleGrabber sampGrabber = null;
            IBaseFilter capFilter = null;
            ICaptureGraphBuilder2 capGraph = null;

            // Get the graphbuilder object
            m_FilterGraph = (IFilterGraph2) new FilterGraph();
            m_mediaCtrl = m_FilterGraph as IMediaControl;
            try
            {
                // Get the ICaptureGraphBuilder2
                capGraph = (ICaptureGraphBuilder2) new CaptureGraphBuilder2();

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

                // Start building the graph
                hr = capGraph.SetFiltergraph( m_FilterGraph );
                DsError.ThrowExceptionForHR( hr );

                // Add the video device
                hr = m_FilterGraph.AddSourceFilterForMoniker(dev.Mon, null, "Video input", out capFilter);
                DsError.ThrowExceptionForHR( hr );

                IBaseFilter baseGrabFlt = (IBaseFilter)	sampGrabber;
                ConfigureSampleGrabber(sampGrabber);

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

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

                hr = capGraph.RenderStream( PinCategory.Capture, MediaType.Video, capFilter, null, baseGrabFlt );
                DsError.ThrowExceptionForHR( hr );

                SaveSizeInfo(sampGrabber);
            }
            finally
            {
                if (capFilter != null)
                {
                    Marshal.ReleaseComObject(capFilter);
                    capFilter = null;
                }
                if (sampGrabber != null)
                {
                    Marshal.ReleaseComObject(sampGrabber);
                    sampGrabber = null;
                }
                if (capGraph != null)
                {
                    Marshal.ReleaseComObject(capGraph);
                    capGraph = null;
                }
            }
        }
开发者ID:eaglezhao,项目名称:tracnghiemweb,代码行数:65,代码来源:Capture.cs

示例4: SetupGraph

        /// <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;

            // 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);
                }

                // 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);
                    }
                }

//.........这里部分代码省略.........
开发者ID:SaintLoong,项目名称:RemoteControl_Server,代码行数:101,代码来源:Capture.cs

示例5: SetupGraph

        /// <summary> build the capture graph for grabber. </summary>
        private void SetupGraph(string FileName)
        {
            int hr;

            ISampleGrabber sampGrabber = null;
            IBaseFilter baseGrabFlt = null;
            IBaseFilter capFilter = null;
            IBaseFilter nullrenderer = null;

            // Get the graphbuilder object
            m_FilterGraph = new FilterGraph() as IFilterGraph2;
            m_mediaCtrl = m_FilterGraph as IMediaControl;
            m_MediaEvent = m_FilterGraph as IMediaEvent;

            IMediaFilter mediaFilt = m_FilterGraph as IMediaFilter;

            try
            {
            #if DEBUG
                m_rot = new DsROTEntry(m_FilterGraph);
            #endif

                // Add the video source
                hr = m_FilterGraph.AddSourceFilter(FileName, "Ds.NET FileFilter", out capFilter);
                DsError.ThrowExceptionForHR(hr);

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

                ConfigureSampleGrabber(sampGrabber);

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

                // ---------------------------------
                // Connect the file filter to the sample grabber

                // Hopefully this will be the video pin, we could check by reading it's mediatype
                IPin iPinOut = DsFindPin.ByDirection(capFilter, PinDirection.Output, 0);

                // Get the input pin from the sample grabber
                IPin iPinIn = DsFindPin.ByDirection(baseGrabFlt, PinDirection.Input, 0);

                hr = m_FilterGraph.Connect(iPinOut, iPinIn);
                DsError.ThrowExceptionForHR(hr);

                // Add the null renderer to the graph
                nullrenderer = new NullRenderer() as IBaseFilter;
                hr = m_FilterGraph.AddFilter(nullrenderer, "Null renderer");
                DsError.ThrowExceptionForHR(hr);

                // ---------------------------------
                // Connect the sample grabber to the null renderer

                iPinOut = DsFindPin.ByDirection(baseGrabFlt, PinDirection.Output, 0);
                iPinIn = DsFindPin.ByDirection(nullrenderer, PinDirection.Input, 0);

                hr = m_FilterGraph.Connect(iPinOut, iPinIn);
                DsError.ThrowExceptionForHR(hr);

                // Turn off the clock.  This causes the frames to be sent
                // thru the graph as fast as possible
                hr = mediaFilt.SetSyncSource(null);
                DsError.ThrowExceptionForHR(hr);

                // Read and cache the image sizes
                SaveSizeInfo(sampGrabber);
            }
            finally
            {
                if (capFilter != null)
                {
                    Marshal.ReleaseComObject(capFilter);
                    capFilter = null;
                }
                if (sampGrabber != null)
                {
                    Marshal.ReleaseComObject(sampGrabber);
                    sampGrabber = null;
                }
                if (nullrenderer != null)
                {
                    Marshal.ReleaseComObject(nullrenderer);
                    nullrenderer = null;
                }
            }
        }
开发者ID:nikolasbe,项目名称:ugent-dma-videoshotdetection,代码行数:90,代码来源:Capture.cs

示例6: BuildGraph

        private void BuildGraph(string fileName)
        {
            int hr = 0;

            try
            {
                graphBuilder = (IFilterGraph2) new FilterGraph();
                mediaControl = (IMediaControl) graphBuilder;

                vmr9 = (IBaseFilter) new VideoMixingRenderer9();

                ConfigureVMR9InWindowlessMode();

                hr = graphBuilder.AddFilter(vmr9, "Video Mixing Renderer 9");
                DsError.ThrowExceptionForHR(hr);

                hr = graphBuilder.RenderFile(fileName, null);
                DsError.ThrowExceptionForHR(hr);

                mixerBitmap = (IVMRMixerBitmap9) vmr9;

                menuMixer.Enabled = true;
                mixerEnabled = true;
                usingGDI = false;
                UpdateMixerMenu();
                SetMixerSettings();
            }
            catch(Exception e)
            {
                CloseInterfaces();
                MessageBox.Show("An error occured during the graph building : \r\n\r\n" + e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
开发者ID:adambyram,项目名称:pimaker,代码行数:33,代码来源:MainForm.cs

示例7: SetupGraph

        /// <summary> build the capture graph for grabber. </summary>
        private void SetupGraph(DsDevice dev, int iSampleRate, int iChannels)
        {
            int hr;

            ISampleGrabber sampGrabber = null;
            IBaseFilter capFilter = null;
            ICaptureGraphBuilder2 capGraph = null;
            IBaseFilter baseGrabFlt = null;
            IBaseFilter nullrenderer = null;
            IMediaFilter mediaFilt = m_FilterGraph as IMediaFilter;

            // Get the graphbuilder object
            m_FilterGraph = (IFilterGraph2)new FilterGraph();
            m_mediaCtrl = m_FilterGraph as IMediaControl;
            try {
                // Get the ICaptureGraphBuilder2
                capGraph = (ICaptureGraphBuilder2)new CaptureGraphBuilder2();

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

                // Start building the graph
                hr = capGraph.SetFiltergraph(m_FilterGraph);
                DsError.ThrowExceptionForHR(hr);

                // Add the audio device
                hr = m_FilterGraph.AddSourceFilterForMoniker(dev.Mon, null, "Audio input", out capFilter);
                DsError.ThrowExceptionForHR(hr);

                // If any of the default config items are set
                if (iSampleRate + iChannels > 0) {
                    SetConfigParms(capGraph, capFilter, iSampleRate, iChannels);
                }

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

                ConfigureSampleGrabber(sampGrabber);

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

                // ---------------------------------
                // Connect the file filter to the sample grabber

                // Hopefully this will be the audio pin, we could check by reading it's mediatype
                IPin iPinOut = DsFindPin.ByDirection(capFilter, PinDirection.Output, 0);

                // Get the input pin from the sample grabber
                IPin iPinIn = DsFindPin.ByDirection(baseGrabFlt, PinDirection.Input, 0);

                hr = m_FilterGraph.Connect(iPinOut, iPinIn);
                DsError.ThrowExceptionForHR(hr);

                // Add the null renderer to the graph
                nullrenderer = new NullRenderer() as IBaseFilter;
                hr = m_FilterGraph.AddFilter(nullrenderer, "Null renderer");
                DsError.ThrowExceptionForHR(hr);

                // ---------------------------------
                // Connect the sample grabber to the null renderer
                iPinOut = DsFindPin.ByDirection(baseGrabFlt, PinDirection.Output, 0);
                iPinIn = DsFindPin.ByDirection(nullrenderer, PinDirection.Input, 0);

                hr = m_FilterGraph.Connect(iPinOut, iPinIn);
                DsError.ThrowExceptionForHR(hr);

                // Read and cache the resulting settings
                SaveSizeInfo(sampGrabber);
            } finally {
                if (capFilter != null) {
                    Marshal.ReleaseComObject(capFilter);
                    capFilter = null;
                }
                if (sampGrabber != null) {
                    Marshal.ReleaseComObject(sampGrabber);
                    sampGrabber = null;
                }
                if (capGraph != null) {
                    Marshal.ReleaseComObject(capGraph);
                    capGraph = null;
                }
            }
        }
开发者ID:i-e-b,项目名称:HLS---Smooth-Encoder,代码行数:87,代码来源:AudioCapture.cs

示例8: Caps

        /// <summary>
        /// Returns the <see cref="CameraInfo"/> for the given <see cref="DsDevice"/>.
        /// </summary>
        /// <param name="dev">A <see cref="DsDevice"/> to parse name and capabilities for.</param>
        /// <returns>The <see cref="CameraInfo"/> for the given device.</returns>
        private CameraInfo Caps(DsDevice dev)
        {
            var camerainfo = new CameraInfo();

            try
            {
                // Get the graphbuilder object
                m_graphBuilder = (IFilterGraph2) new FilterGraph();

                // Get the ICaptureGraphBuilder2
                capGraph = (ICaptureGraphBuilder2) new CaptureGraphBuilder2();

                // Add the video device
                int hr = m_graphBuilder.AddSourceFilterForMoniker(dev.Mon, null, "Video input", out capFilter);
                //DsError.ThrowExceptionForHR(hr);

                if (hr != 0)
                {
                    return null;
                }

                hr = capGraph.SetFiltergraph(m_graphBuilder);
                DsError.ThrowExceptionForHR(hr);

                hr = m_graphBuilder.AddFilter(capFilter, "Ds.NET Video Capture Device");
                DsError.ThrowExceptionForHR(hr);

                object o = null;
                DsGuid cat = PinCategory.Capture;
                DsGuid type = MediaType.Interleaved;
                DsGuid iid = typeof (IAMStreamConfig).GUID;

                // Check if Video capture filter is in use
                hr = capGraph.RenderStream(cat, MediaType.Video, capFilter, null, null);
                if (hr != 0)
                {
                    return null;
                }

                //hr = capGraph.FindInterface(PinCategory.Capture, MediaType.Interleaved, capFilter, typeof(IAMStreamConfig).GUID, out o);
                //if (hr != 0)
                //{
                hr = capGraph.FindInterface(PinCategory.Capture, MediaType.Video, capFilter,
                                            typeof (IAMStreamConfig).GUID, out o);
                DsError.ThrowExceptionForHR(hr);
                //}

                var videoStreamConfig = o as IAMStreamConfig;

                int iCount = 0;
                int iSize = 0;

                try
                {
                    if (videoStreamConfig != null) videoStreamConfig.GetNumberOfCapabilities(out iCount, out iSize);
                }
                catch (Exception ex)
                {
                    //ErrorLogger.ProcessException(ex, false);
                    return null;
                }

                pscc = Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof (VideoStreamConfigCaps)));

                camerainfo.Name = dev.Name;
                camerainfo.DirectshowDevice = dev;

                for (int i = 0; i < iCount; i++)
                {
                    VideoStreamConfigCaps scc;

                    try
                    {
                        AMMediaType curMedType;
                        if (videoStreamConfig != null) hr = videoStreamConfig.GetStreamCaps(i, out curMedType, pscc);
                        Marshal.ThrowExceptionForHR(hr);
                        scc = (VideoStreamConfigCaps) Marshal.PtrToStructure(pscc, typeof (VideoStreamConfigCaps));

                        var CSF = new CamSizeFPS();
                        CSF.FPS = (int) (10000000/scc.MinFrameInterval);
                        CSF.Height = scc.InputSize.Height;
                        CSF.Width = scc.InputSize.Width;

                        if (!InSizeFpsList(camerainfo.SupportedSizesAndFPS, CSF))
                            if (ParametersOK(CSF))
                                camerainfo.SupportedSizesAndFPS.Add(CSF);
                    }
                    catch (Exception ex)
                    {
                        //ErrorLogger.ProcessException(ex, false);
                    }
                }
            }
            finally
            {
//.........这里部分代码省略.........
开发者ID:jonbyte,项目名称:EyeSpark,代码行数:101,代码来源:DirectShowDevices.cs

示例9: SetupGraph

    /// <summary>
    /// Connects to the property changed events of the camera settings.
    /// </summary>
    //private void Initialize()
    //{
    //    //Settings.Instance.Camera.OnCameraControlPropertyChanged += OnCameraControlPropertyChanged;
    //    //Settings.Instance.Camera.OnVideoProcAmpPropertyChanged += OnVideoProcAmpPropertyChanged;
    //    //Settings.Instance.Camera.OnVideoControlFlagsChanged += OnVideoControlFlagsChanged;

    //    //stopwatch = new Stopwatch();
    //}

    /// <summary>
    /// Build the capture graph for grabber. 
    /// </summary>
    /// <param name="dev">The index of the new capture device.</param>
    /// <param name="frameRate">The framerate to use.</param>
    /// <param name="width">The width to use.</param>
    /// <param name="height">The height to use.</param>
    /// <returns>True, if successful, otherwise false.</returns>
    private bool SetupGraph(DsDevice dev, int frameRate, int width, int height)
    {
      int hr;
      fps = frameRate; // Not measured, only to expose FPS externally 
      cameraControl = null;
      capFilter = null;

      // Get the graphbuilder object
      graphBuilder = (IFilterGraph2)new FilterGraph();
      mediaControl = graphBuilder as IMediaControl;

      try
      {
        // Create the ICaptureGraphBuilder2
        capGraph = (ICaptureGraphBuilder2)new CaptureGraphBuilder2();

        // Create the SampleGrabber interface
        sampGrabber = (ISampleGrabber)new SampleGrabber();

        // Start building the graph
        hr = capGraph.SetFiltergraph(graphBuilder);
        //if (hr != 0)
        //    ErrorLogger.WriteLine("Error in capGraph.SetFiltergraph. Could not build graph. Message: " +
        //                          DsError.GetErrorText(hr));

#if DEBUG
        this.rotEntry = new DsROTEntry(this.graphBuilder);
#endif

        this.capFilter = CreateFilter(
       FilterCategory.VideoInputDevice,
       dev.Name);
        if (this.capFilter != null)
        {
          hr = graphBuilder.AddFilter(this.capFilter, "Video Source");
          DsError.ThrowExceptionForHR(hr);
        }

        //// Add the video device
        //hr = graphBuilder.AddSourceFilterForMoniker(dev.Mon, null, "Video input", out capFilter);
        //if (hr != 0)
        //    ErrorLogger.WriteLine(
        //        "Error in m_graphBuilder.AddSourceFilterForMoniker(). Could not add source filter. Message: " +
        //        DsError.GetErrorText(hr));

        var baseGrabFlt = (IBaseFilter)sampGrabber;

        ConfigureSampleGrabber(sampGrabber);

        // Add the frame grabber to the graph
        hr = graphBuilder.AddFilter(baseGrabFlt, "Ds.NET Grabber");

        //if (hr != 0)
        //    ErrorLogger.WriteLine("Error in m_graphBuilder.AddFilter(). Could not add filter. Message: " +
        //                          DsError.GetErrorText(hr));

        // turn on the infrared leds ONLY FOR THE GENIUS WEBCAM
        /*
        if (!defaultMode)
        {
            m_icc = capFilter as IAMCameraControl;
            CameraControlFlags CamFlags = new CameraControlFlags();
            int pMin, pMax, pStep, pDefault;

            hr = m_icc.GetRange(CameraControlProperty.Focus, out pMin, out pMax, out pStep, out pDefault, out CamFlags);
            m_icc.Set(CameraControlProperty.Focus, pMax, CameraControlFlags.None);
        }
        */


        //IBaseFilter smartTee = new SmartTee() as IBaseFilter;

        //// Add the smart tee filter to the graph
        //hr = this.graphBuilder.AddFilter(smartTee, "Smart Tee");
        //Marshal.ThrowExceptionForHR(hr);

        // Connect the video source output to the smart tee
        //hr = capGraph.RenderStream(null, null, capFilter, null, smartTee);

        hr = capGraph.RenderStream(PinCategory.Capture, MediaType.Video, capFilter, null, baseGrabFlt);
//.........这里部分代码省略.........
开发者ID:DeSciL,项目名称:Ogama,代码行数:101,代码来源:DirectShowCamera.cs

示例10: AddMpegMuxer

 /// <summary>
 /// Adds the MPEG muxer filter
 /// </summary>
 /// <param name="_graphBuilder">GraphBuilder</param>
 /// <param name="_capture">Capture</param>
 /// <returns></returns>
 private bool AddMpegMuxer(IFilterGraph2 _graphBuilder, Capture _capture)
 {
   Log.Log.WriteFile("analog:AddMpegMuxer()");
   try
   {
     const string monikerPowerDirectorMuxer =
       @"@device:sw:{083863F1-70DE-11D0-BD40-00A0C911CE86}\{7F2BBEAF-E11C-4D39-90E8-938FB5A86045}";
     const string monikerPowerDvdMuxer =
       @"@device:sw:{083863F1-70DE-11D0-BD40-00A0C911CE86}\{6770E328-9B73-40C5-91E6-E2F321AEDE57}";
     const string monikerPowerDvdMuxer2 =
       @"@device:sw:{083863F1-70DE-11D0-BD40-00A0C911CE86}\{370E9701-9DC5-42C8-BE29-4E75F0629EED}";
     _filterMpegMuxer = Marshal.BindToMoniker(monikerPowerDirectorMuxer) as IBaseFilter;
     int hr = _graphBuilder.AddFilter(_filterMpegMuxer, "CyberLink MPEG Muxer");
     if (hr != 0)
     {
       _filterMpegMuxer = Marshal.BindToMoniker(monikerPowerDvdMuxer) as IBaseFilter;
       hr = _graphBuilder.AddFilter(_filterMpegMuxer, "CyberLink MPEG Muxer");
       if (hr != 0)
       {
         _filterMpegMuxer = Marshal.BindToMoniker(monikerPowerDvdMuxer2) as IBaseFilter;
         hr = _graphBuilder.AddFilter(_filterMpegMuxer, "CyberLink MPEG Muxer");
         if (hr != 0)
         {
           Log.Log.WriteFile("analog:AddMpegMuxer returns:0x{0:X}", hr);
           //throw new TvException("Unable to add Cyberlink MPEG Muxer");
         }
       }
     }
     Log.Log.WriteFile("analog:connect pinvideo {0} ->mpeg muxer", FilterGraphTools.LogPinInfo(_pinVideo));
     if (!FilterGraphTools.ConnectPin(_graphBuilder, _pinVideo, _filterMpegMuxer, 0))
     {
       Log.Log.WriteFile("analog: unable to connect pinvideo->mpeg muxer");
       throw new TvException("Unable to connect pins");
     }
     _pinVideoConnected = true;
     Log.Log.WriteFile("analog: connected pinvideo->mpeg muxer");
     // Some Adaptec devices use the LPCM pin for audio so we check this can connect if applicable.
     // Note that this does *not* apply to the Adaptec AVC-3610.
     bool isAdaptec = false;
     if (!_capture.VideoCaptureDevicePath.ToLower().StartsWith(@"@device:pnp:\\?\usb#vid_03f3&pid_0091#") && // Adaptec AVC-3610 tuner 1
         !_capture.VideoCaptureDevicePath.ToLower().StartsWith(@"@device:pnp:\\?\usb#vid_03f3&pid_0093#") && // Adaptec AVC-3610 tuner 2
         (
           _capture.VideoCaptureName.Contains("Adaptec USB Capture Device") ||
           _capture.VideoCaptureName.Contains("Adaptec PCI Capture Device") ||
           _capture.AudioCaptureName.Contains("Adaptec USB Capture Device") ||
           _capture.AudioCaptureName.Contains("Adaptec PCI Capture Device")
         )
     )
     {
       Log.Log.WriteFile("analog: AddMpegMuxer, Adaptec device found using LPCM");
       isAdaptec = true;
     }
     if (isAdaptec)
     {
       if (!FilterGraphTools.ConnectPin(_graphBuilder, _pinLPCM, _filterMpegMuxer, 1))
       {
         Log.Log.WriteFile("analog: AddMpegMuxer, unable to connect pinLPCM->mpeg muxer");
         throw new TvException("Unable to connect pins");
       }
       Log.Log.WriteFile("analog: AddMpegMuxer, connected pinLPCM->mpeg muxer");
     }
     else
     {
       Log.Log.WriteFile("analog:connect pinaudio {0} ->mpeg muxer", FilterGraphTools.LogPinInfo(_pinAudio));
       if (!FilterGraphTools.ConnectPin(_graphBuilder, _pinAudio, _filterMpegMuxer, 1))
       {
         Log.Log.WriteFile("analog:AddMpegMuxer, unable to connect pinaudio->mpeg muxer");
         throw new TvException("Unable to connect pins");
       }
       Log.Log.WriteFile("analog:AddMpegMuxer, connected pinaudio->mpeg muxer");
     }
     return true;
   }
   catch (Exception ex)
   {
     throw new TvException("Cyberlink MPEG Muxer filter (mpgmux.ax) not installed " + ex.Message);
   }
 }
开发者ID:npcomplete111,项目名称:MediaPortal-1,代码行数:84,代码来源:Encoder.cs

示例11: Play

    public bool Play(string fileName, Form form)
    {
      fileName += ".tsbuffer";
      Log.WriteFile("play:{0}", fileName);
      _graphBuilder = (IFilterGraph2)new FilterGraph();
      _rotEntry = new DsROTEntry(_graphBuilder);


      Log.WriteFile("add tsfilesource");
      _tsFileSource = new TsFileSource();
      _graphBuilder.AddFilter((IBaseFilter)_tsFileSource, "TsFileSource");

      #region add mpeg-2 demux filter

      Log.WriteFile("add mpeg-2 demux");
      MPEG2Demultiplexer demux = new MPEG2Demultiplexer();
      _mpegDemux = (IBaseFilter)demux;
      int hr = _graphBuilder.AddFilter(_mpegDemux, "MPEG-2 Demultiplexer");

      #endregion

      #region create mpeg2 demux pins

      Log.WriteFile("create mpeg-2 demux pins");
      //create mpeg-2 demux output pins
      IMpeg2Demultiplexer demuxer = _mpegDemux as IMpeg2Demultiplexer;


      if (demuxer != null)
        hr = demuxer.CreateOutputPin(GetAudioMpg2Media(), "Audio", out _pinAudio);
      if (hr != 0)
      {
        Log.WriteFile("unable to create audio pin");
        return false;
      }
      if (demuxer != null)
        hr = demuxer.CreateOutputPin(GetVideoMpg2Media(), "Video", out _pinVideo);
      if (hr != 0)
      {
        Log.WriteFile("unable to create video pin");
        return false;
      }

      #endregion

      #region load file in tsfilesource

      Log.WriteFile("load file in tsfilesource");
      IFileSourceFilter interfaceFile = (IFileSourceFilter)_tsFileSource;
      if (interfaceFile == null)
      {
        Log.WriteFile("TSStreamBufferPlayer9:Failed to get IFileSourceFilter");
        return false;
      }

      AMMediaType mpeg2ProgramStream = new AMMediaType();
      mpeg2ProgramStream.majorType = MediaType.Stream;
      mpeg2ProgramStream.subType = MediaSubType.Mpeg2Program;

      mpeg2ProgramStream.unkPtr = IntPtr.Zero;
      mpeg2ProgramStream.sampleSize = 0;
      mpeg2ProgramStream.temporalCompression = false;
      mpeg2ProgramStream.fixedSizeSamples = true;
      mpeg2ProgramStream.formatType = FormatType.None;
      mpeg2ProgramStream.formatSize = 0;
      mpeg2ProgramStream.formatPtr = IntPtr.Zero;
      hr = interfaceFile.Load(fileName, mpeg2ProgramStream);

      if (hr != 0)
      {
        Log.WriteFile("TSStreamBufferPlayer9:Failed to load file");
        return false;
      }

      #region connect tsfilesource->demux

      Log.WriteFile("connect tsfilesource->demux");
      Log.WriteFile("TSStreamBufferPlayer9:connect tsfilesource->mpeg2 demux");
      IPin pinTsOut = DsFindPin.ByDirection((IBaseFilter)_tsFileSource, PinDirection.Output, 0);
      if (pinTsOut == null)
      {
        Log.WriteFile("TSStreamBufferPlayer9:failed to find output pin of tsfilesource");
        return false;
      }
      IPin pinDemuxIn = DsFindPin.ByDirection(_mpegDemux, PinDirection.Input, 0);
      if (pinDemuxIn == null)
      {
        Log.WriteFile("TSStreamBufferPlayer9:failed to find output pin of tsfilesource");
        return false;
      }

      hr = _graphBuilder.Connect(pinTsOut, pinDemuxIn);
      if (hr != 0)
      {
        Log.WriteFile("TSStreamBufferPlayer9:failed to connect tsfilesource->mpeg2 demux:{0:X}", hr);
        return false;
      }
      Release.ComObject(pinTsOut);
      Release.ComObject(pinDemuxIn);

//.........这里部分代码省略.........
开发者ID:arangas,项目名称:MediaPortal-1,代码行数:101,代码来源:player.cs

示例12: AddMpeg2Demultiplexer

 /// <summary>
 /// Adds a mpeg2 demultiplexer to the graph
 /// </summary>
 /// <param name="_graphBuilder">The graph builder</param>
 private void AddMpeg2Demultiplexer(IFilterGraph2 _graphBuilder)
 {
   Log.Log.WriteFile("analog: AddMpeg2Demultiplexer");
   if (_filterMpeg2Demux != null)
     return;
   if (_pinCapture == null)
     return;
   _filterMpeg2Demux = (IBaseFilter)new MPEG2Demultiplexer();
   int hr = _graphBuilder.AddFilter(_filterMpeg2Demux, "MPEG2 Demultiplexer");
   if (hr != 0)
   {
     Log.Log.WriteFile("analog: AddMPEG2DemuxFilter returns:0x{0:X}", hr);
     throw new TvException("Unable to add MPEG2 demultiplexer");
   }
   Log.Log.WriteFile("analog: connect capture->mpeg2 demux");
   IPin pin = DsFindPin.ByDirection(_filterMpeg2Demux, PinDirection.Input, 0);
   hr = _graphBuilder.Connect(_pinCapture, pin);
   if (hr != 0)
   {
     Log.Log.WriteFile("analog: ConnectFilters returns:0x{0:X}", hr);
     throw new TvException("Unable to connect capture-> MPEG2 demultiplexer");
   }
   IMpeg2Demultiplexer demuxer = (IMpeg2Demultiplexer)_filterMpeg2Demux;
   demuxer.CreateOutputPin(FilterGraphTools.GetVideoMpg2Media(), "Video", out _pinVideo);
   demuxer.CreateOutputPin(FilterGraphTools.GetAudioMpg2Media(), "Audio", out _pinAudio);
   demuxer.CreateOutputPin(FilterGraphTools.GetAudioLPCMMedia(), "LPCM", out _pinLPCM);
   IMPEG2StreamIdMap map = (IMPEG2StreamIdMap)_pinVideo;
   map.MapStreamId(224, MPEG2Program.ElementaryStream, 0, 0);
   map = (IMPEG2StreamIdMap)_pinAudio;
   map.MapStreamId(0xC0, MPEG2Program.ElementaryStream, 0, 0);
   map = (IMPEG2StreamIdMap)_pinLPCM;
   map.MapStreamId(0xBD, MPEG2Program.ElementaryStream, 0xA0, 7);
 }
开发者ID:npcomplete111,项目名称:MediaPortal-1,代码行数:37,代码来源:Encoder.cs

示例13: AddInterVideoMuxer

 /// <summary>
 /// Adds the InterVideo muxer and connects the compressor to it.
 /// This is the preferred muxer for Plextor cards and others.
 /// It will be used if the InterVideo Audio Encoder is used also.
 /// </summary>
 /// <param name="_graphBuilder">GraphBuilder</param>
 /// <param name="_capture">Capture</param>
 /// <returns></returns>
 private bool AddInterVideoMuxer(IFilterGraph2 _graphBuilder, Capture _capture)
 {
   IPin pinOut;
   Log.Log.Info("analog:  using intervideo muxer");
   string muxVideoIn = "video compressor";
   const string monikerInterVideoMuxer =
     @"@device:sw:{083863F1-70DE-11D0-BD40-00A0C911CE86}\{317DDB63-870E-11D3-9C32-00104B3801F7}";
   _filterAnalogMpegMuxer = Marshal.BindToMoniker(monikerInterVideoMuxer) as IBaseFilter;
   int hr = _graphBuilder.AddFilter(_filterAnalogMpegMuxer, "InterVideo MPEG Muxer");
   if (hr != 0)
   {
     Log.Log.WriteFile("analog:  add intervideo muxer returns:0x{0:X}", hr);
     throw new TvException("Unable to add InterVideo Muxer");
   }
   Log.Log.Info("analog:  add intervideo muxer successful");
   // next connect video compressor->muxer
   if (_isPlextorConvertX)
   {
     muxVideoIn = "Plextor ConvertX";
     //no video compressor needed with the Plextor device so we use the first capture pin
     pinOut = DsFindPin.ByDirection(_capture.VideoFilter, PinDirection.Output, 0);
   }
   else
   {
     pinOut = DsFindPin.ByDirection(_filterVideoCompressor, PinDirection.Output, 0);
   }
   IPin pinIn = DsFindPin.ByDirection(_filterAnalogMpegMuxer, PinDirection.Input, 0);
   if (pinOut == null)
   {
     Log.Log.Info("analog:  no output pin found on {0}", muxVideoIn);
     throw new TvException("no output pin found on video out");
   }
   if (pinIn == null)
   {
     Log.Log.Info("analog:  no input pin found on intervideo muxer");
     throw new TvException("no input pin found on intervideo muxer");
   }
   hr = _graphBuilder.Connect(pinOut, pinIn);
   if (hr != 0)
   {
     Log.Log.WriteFile("analog:  unable to connect {0}-> intervideo muxer returns:0x{1:X}", muxVideoIn, hr);
     throw new TvException("Unable to add unable to connect to video in on intervideo muxer");
   }
   Log.Log.WriteFile("analog:  connected video -> intervideo muxer");
   // next connect audio compressor->muxer
   pinOut = DsFindPin.ByDirection(_filterAudioCompressor, PinDirection.Output, 0);
   pinIn = DsFindPin.ByDirection(_filterAnalogMpegMuxer, PinDirection.Input, 1);
   if (pinOut == null)
   {
     Log.Log.Info("analog:  no output pin found on audio compressor");
     throw new TvException("no output pin found on audio compressor");
   }
   if (pinIn == null)
   {
     Log.Log.Info("analog:  no input pin found on intervideo muxer");
     throw new TvException("no input pin found on intervideo muxer");
   }
   hr = _graphBuilder.Connect(pinOut, pinIn);
   if (hr != 0)
   {
     Log.Log.WriteFile("analog:unable to connect audio compressor->intervideo muxer returns:0x{0:X}", hr);
     throw new TvException("Unable to add unable to connect audio compressor->intervideo muxer");
   }
   Log.Log.WriteFile("analog:  connected audio -> intervideo muxer");
   //and finally we have a capture pin...
   _pinCapture = DsFindPin.ByDirection(_filterAnalogMpegMuxer, PinDirection.Output, 0);
   if (_pinCapture == null)
   {
     Log.Log.WriteFile("analog:unable find capture pin");
     throw new TvException("unable find capture pin");
   }
   return true;
 }
开发者ID:npcomplete111,项目名称:MediaPortal-1,代码行数:81,代码来源:Encoder.cs

示例14: AddAnalogMuxer

 /// <summary>
 /// Adds the mpeg muxer
 /// </summary>
 /// <param name="_graphBuilder">GraphBuilder</param>
 /// <returns></returns>
 private bool AddAnalogMuxer(IFilterGraph2 _graphBuilder)
 {
   Log.Log.Info("analog:AddAnalogMuxer");
   const string monikerPowerDirectorMuxer =
     @"@device:sw:{083863F1-70DE-11D0-BD40-00A0C911CE86}\{7F2BBEAF-E11C-4D39-90E8-938FB5A86045}";
   _filterAnalogMpegMuxer = Marshal.BindToMoniker(monikerPowerDirectorMuxer) as IBaseFilter;
   int hr = _graphBuilder.AddFilter(_filterAnalogMpegMuxer, "Analog MPEG Muxer");
   if (hr != 0)
   {
     Log.Log.WriteFile("analog:AddAnalogMuxer returns:0x{0:X}", hr);
     throw new TvException("Unable to add AddAnalogMuxer");
   }
   // next connect audio compressor->muxer
   IPin pinOut = DsFindPin.ByDirection(_filterAudioCompressor, PinDirection.Output, 0);
   IPin pinIn = DsFindPin.ByDirection(_filterAnalogMpegMuxer, PinDirection.Input, 1);
   if (pinOut == null)
   {
     Log.Log.Info("analog:no output pin found on audio compressor");
     throw new TvException("no output pin found on audio compressor");
   }
   if (pinIn == null)
   {
     Log.Log.Info("analog:no input pin found on analog muxer");
     throw new TvException("no input pin found on muxer");
   }
   hr = _graphBuilder.Connect(pinOut, pinIn);
   if (hr != 0)
   {
     Log.Log.WriteFile("analog:unable to connect audio compressor->muxer returns:0x{0:X}", hr);
     throw new TvException("Unable to add unable to connect audio compressor->muxer");
   }
   Log.Log.WriteFile("analog:  connected audio -> muxer");
   // next connect video compressor->muxer
   pinOut = DsFindPin.ByDirection(_filterVideoCompressor, PinDirection.Output, 0);
   pinIn = DsFindPin.ByDirection(_filterAnalogMpegMuxer, PinDirection.Input, 0);
   if (pinOut == null)
   {
     Log.Log.Info("analog:no output pin found on video compressor");
     throw new TvException("no output pin found on video compressor");
   }
   if (pinIn == null)
   {
     Log.Log.Info("analog:no input pin found on analog muxer");
     throw new TvException("no input pin found on muxer");
   }
   hr = _graphBuilder.Connect(pinOut, pinIn);
   if (hr != 0)
   {
     Log.Log.WriteFile("analog:unable to connect video compressor->muxer returns:0x{0:X}", hr);
     throw new TvException("Unable to add unable to connect video compressor->muxer");
   }
   //and finally we have a capture pin...
   Log.Log.WriteFile("analog:  connected video -> muxer");
   _pinCapture = DsFindPin.ByDirection(_filterAnalogMpegMuxer, PinDirection.Output, 0);
   if (_pinCapture == null)
   {
     Log.Log.WriteFile("analog:unable find capture pin");
     throw new TvException("unable find capture pin");
   }
   return true;
 }
开发者ID:npcomplete111,项目名称:MediaPortal-1,代码行数:66,代码来源:Encoder.cs

示例15: BuildGraph

        private void BuildGraph(Control hControl)
        {
            int hr;
            DsDevice [] devs;
            IBaseFilter ibfSource = null;
            IBaseFilter dmoFilter = null;
            IBaseFilter ibfRender = null;
            IDMOWrapperFilter dmoWrapperFilter = null;

            ICaptureGraphBuilder2 icgb = (ICaptureGraphBuilder2)new CaptureGraphBuilder2();

            graphBuilder = (IFilterGraph2) new FilterGraph();
            #if DEBUG
            m_rot = new DsROTEntry(graphBuilder);
            #endif

            hr = icgb.SetFiltergraph(graphBuilder);
            DsError.ThrowExceptionForHR(hr);

            devs = DsDevice.GetDevicesOfCat(FilterCategory.VideoInputDevice);

            if (devs.Length < 1)
            {
                throw new Exception("This sample requires a capture device.  If you don't " +
                    "have a capture device, change the BuildGraph routine to use AddSourceFilter " +
                    "and use a file.");
            }

            // Add a source filter
            hr = graphBuilder.AddSourceFilterForMoniker(devs[0].Mon, null, "Video Input Device", out ibfSource);
            DsError.ThrowExceptionForHR(hr);

            // Add a DMO Wrapper Filter
            dmoFilter = (IBaseFilter) new DMOWrapperFilter();
            dmoWrapperFilter = (IDMOWrapperFilter) dmoFilter;

            // Since I know the guid of the DMO I am looking for, I *could* do this.
            //hr = dmoWrapperFilter.Init(new Guid("{7EF28FD7-E88F-45bb-9CDD-8A62956F2D75}"), DMOCatergory.VideoEffect);
            //DMOError.ThrowExceptionForHR(hr);

            // But it is more useful to show how to scan for the DMO
            Guid g = FindGuid("DmoFlip", DMOCategory.VideoEffect);

            hr = dmoWrapperFilter.Init(g, DMOCategory.VideoEffect);
            DMOError.ThrowExceptionForHR(hr);

            SetDMOParams(dmoFilter);

            // Add it to the Graph
            hr = graphBuilder.AddFilter(dmoFilter, "DMO Filter");
            DsError.ThrowExceptionForHR(hr);

            ibfRender = (IBaseFilter)new VideoRenderer();
            hr = graphBuilder.AddFilter(ibfRender, "renderer");
            DsError.ThrowExceptionForHR(hr);

            hr = icgb.RenderStream(null, null, ibfSource, dmoFilter, ibfRender);
            DsError.ThrowExceptionForHR(hr);

            ConfigVideo(graphBuilder as IVideoWindow, hControl);

            Marshal.ReleaseComObject(ibfSource);
            Marshal.ReleaseComObject(ibfRender);
        }
开发者ID:OmerMor,项目名称:DirectShowLib-FORK,代码行数:64,代码来源:Form1.cs


注:本文中的IFilterGraph2.AddFilter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。