• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# IMediaSeeking类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中IMediaSeeking的典型用法代码示例。如果您正苦于以下问题:C# IMediaSeeking类的具体用法?C# IMediaSeeking怎么用?C# IMediaSeeking使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IMediaSeeking类属于命名空间,在下文中一共展示了IMediaSeeking类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: PlayerCore

        public PlayerCore(string file)
        {
            graphBuilder = (new FilterGraph()) as IFilterGraph2;
            if (graphBuilder == null) return;
            mediaControl = graphBuilder as IMediaControl;
            mediaSeeking = graphBuilder as IMediaSeeking;
            audioControl = graphBuilder as IBasicAudio;
            if (mediaControl == null || mediaSeeking == null || audioControl == null) return;
            //int hr = mediaControl.RenderFile(file);
            FileInfo info = new FileInfo(file);
            ISupport support = Supports.Instance[info.Extension];
            int hr = -1;
            if (support != null)
                hr = support.RenderGraph(graphBuilder, file);
            else
                hr = mediaControl.RenderFile(file);

            fileName = file;
            if (hr != 0) errorStack.Push(hr);
            if (hr != 0) return;
            mediaSeeking.SetTimeFormat(TimeFormat.MediaTime);
            isValidate = true;
            window = graphBuilder as IVideoWindow;
            if (window != null)
            {
                int width = 0;
                int height = 0;
                window.get_Width(out width);
                window.get_Height(out height);
                nativeSize = new Size(width, height);
            }
        }
开发者ID:crazyender,项目名称:Console-Player,代码行数:32,代码来源:core.cs


示例3: setNewPos

 public static void setNewPos(IMediaSeeking mediaSeeking, long newPos, double fps)
 {
     if (mediaSeeking == null) return;
     if (!isInFrames(mediaSeeking))
         newPos = frame2refTime(newPos,fps);
     mediaSeeking.SetPositions(newPos, AMSeekingSeekingFlags.AbsolutePositioning, null, AMSeekingSeekingFlags.NoPositioning);
 }
开发者ID:nuukcillo,项目名称:PerrySub,代码行数:7,代码来源:VideoUnitConversion.cs


示例4: getTotal

 public static int getTotal(IMediaSeeking mediaSeeking, double fps)
 {
     if (mediaSeeking == null) return 1;
     long dur;
     mediaSeeking.GetDuration(out dur);
     if (!isInFrames(mediaSeeking))
         dur = refTime2frame(dur,fps);
     return (int)dur;
 }
开发者ID:nuukcillo,项目名称:PerrySub,代码行数:9,代码来源:VideoUnitConversion.cs


示例5: getCurPos

        public static int getCurPos(IMediaSeeking mediaSeeking, double fps)
        {
            if (mediaSeeking == null) return 1;
            long cur;
            mediaSeeking.GetCurrentPosition(out cur);

            if (!isInFrames(mediaSeeking))
                cur = refTime2frame(cur,fps);

            return (int)cur;
        }
开发者ID:nuukcillo,项目名称:PerrySub,代码行数:11,代码来源:VideoUnitConversion.cs


示例6: InitGraph

    private void InitGraph(string filename)
    {
      int hr = 0;
      //IntPtr hEvent;

      if (filename == string.Empty)
        return;

      this.filterGraph = new FilterGraph() as IFilterGraph2;

#if DEBUG
      //rot = new DsROTEntry(this.filterGraph);
#endif

      // Have the graph builder construct its the appropriate graph automatically
      hr = this.filterGraph.RenderFile(filename, null);
      DsError.ThrowExceptionForHR(hr);
      
      // QueryInterface for DirectShow interfaces
      this.mediaControl = this.filterGraph as IMediaControl;
      this.mediaSeeking = this.filterGraph as IMediaSeeking;
      //this.mediaEvent = this.graphBuilder as IMediaEvent;

      // Query for audio interfaces, which may not be relevant for video-only files
      this.basicAudio = this.filterGraph as IBasicAudio;

      // Complete window initialization
      this.currentPlaybackRate = 1.0;
    }
开发者ID:DeSciL,项目名称:Ogama,代码行数:29,代码来源:AudioPlayer.cs


示例7: SetMediaSeekingInterface

        /// <summary>
        /// Setup the IMediaSeeking interface
        /// </summary>
        protected void SetMediaSeekingInterface(IMediaSeeking mediaSeeking)
        {
            m_mediaSeeking = mediaSeeking;

            if (mediaSeeking == null)
            {
                CurrentPositionFormat = MediaPositionFormat.None;
                Duration = 0;
                return;
            }

            /* Get our prefered DirectShow TimeFormat */
            Guid preferedFormat = ConvertPositionFormat(PreferedPositionFormat);

            /* Attempt to set the time format */
            mediaSeeking.SetTimeFormat(preferedFormat);

            Guid currentFormat;

            /* Gets the current time format
             * we may not have been successful
             * setting our prefered format */
            mediaSeeking.GetTimeFormat(out currentFormat);

            /* Set our property up with the right format */
            CurrentPositionFormat = ConvertPositionFormat(currentFormat);

            SetDuration();
        }
开发者ID:leesanghyun2,项目名称:mp-onlinevideos2,代码行数:32,代码来源:MediaSeekingPlayer.cs


示例8: Transcode


//.........这里部分代码省略.........
        {
          Log.Warn("DVR2MPG: FAILED:unable to get pins of muxer&source");
          Cleanup();
          return false;
        }

        bool usingAc3 = false;
        AMMediaType amAudio = new AMMediaType();
        amAudio.majorType = MediaType.Audio;
        amAudio.subType = MediaSubType.Mpeg2Audio;
        hr = pinOut0.Connect(pinIn1, amAudio);
        if (hr != 0)
        {
          amAudio.subType = MediaSubType.DolbyAC3;
          hr = pinOut0.Connect(pinIn1, amAudio);
          usingAc3 = true;
        }
        if (hr != 0)
        {
          Log.Warn("DVR2MPG: FAILED: unable to connect audio pins: 0x{0:X}", hr);
          Cleanup();
          return false;
        }

        if (usingAc3)
          Log.Info("DVR2MPG: using AC3 audio");
        else
          Log.Info("DVR2MPG: using MPEG audio");

        AMMediaType amVideo = new AMMediaType();
        amVideo.majorType = MediaType.Video;
        amVideo.subType = MediaSubType.Mpeg2Video;
        hr = pinOut1.Connect(pinIn0, amVideo);
        if (hr != 0)
        {
          Log.Warn("DVR2MPG: FAILED: unable to connect video pins: 0x{0:X}", hr);
          Cleanup();
          return false;
        }


        //connect output of powerdvd muxer->input of filewriter
        Log.Info("DVR2MPG: connect multiplexer->filewriter");
        IPin pinOut, pinIn;
        pinOut = DsFindPin.ByDirection(powerDvdMuxer, PinDirection.Output, 0);
        if (pinOut == null)
        {
          Log.Warn("DVR2MPG: FAILED:cannot get output pin of Cyberlink MPEG muxer :0x{0:X}", hr);
          Cleanup();
          return false;
        }
        pinIn = DsFindPin.ByDirection(fileWriterbase, PinDirection.Input, 0);
        if (pinIn == null)
        {
          Log.Warn("DVR2MPG: FAILED:cannot get input pin of Filewriter :0x{0:X}", hr);
          Cleanup();
          return false;
        }
        AMMediaType mt = new AMMediaType();
        hr = pinOut.Connect(pinIn, mt);
        if (hr != 0)
        {
          Log.Warn("DVR2MPG: FAILED:connect muxer->filewriter :0x{0:X}", hr);
          Cleanup();
          return false;
        }

        //set output filename
        string outputFileName = System.IO.Path.ChangeExtension(info.file, ".mpg");
        Log.Info("DVR2MPG: set output file to :{0}", outputFileName);
        mt.majorType = MediaType.Stream;
        mt.subType = MediaSubTypeEx.MPEG2;

        hr = fileWriterFilter.SetFileName(outputFileName, mt);
        if (hr != 0)
        {
          Log.Warn("DVR2MPG: FAILED:unable to set filename for filewriter :0x{0:X}", hr);
          Cleanup();
          return false;
        }
        mediaControl = graphBuilder as IMediaControl;
        mediaSeeking = graphBuilder as IMediaSeeking;
        mediaEvt = graphBuilder as IMediaEventEx;
        Log.Info("DVR2MPG: start transcoding");
        hr = mediaControl.Run();
        if (hr != 0)
        {
          Log.Warn("DVR2MPG: FAILED:unable to start graph :0x{0:X}", hr);
          Cleanup();
          return false;
        }
      }
      catch (Exception ex)
      {
        Log.Error("DVR2MPG: Unable create graph: {0}", ex.Message);
        Cleanup();
        return false;
      }
      return true;
    }
开发者ID:npcomplete111,项目名称:MediaPortal-1,代码行数:101,代码来源:Dvrms2Mpeg.cs


示例9: SetupGraph

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

      // Get the graphbuilder object
      this.graphBuilder = new FilterGraph() as IGraphBuilder;
      this.mediaControl = this.graphBuilder as IMediaControl;
      this.mediaSeeking = this.graphBuilder as IMediaSeeking;
      this.mediaEvent = this.graphBuilder as IMediaEvent;

      try
      {
        // Get the SampleGrabber interface
        this.sampleGrabber = new SampleGrabber() as ISampleGrabber;
        this.sampleGrabberFilter = sampleGrabber as IBaseFilter;

        ConfigureSampleGrabber(sampleGrabber);

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

        IBaseFilter aviSplitter = new AviSplitter() as IBaseFilter;

        // Add the aviSplitter to the graph
        hr = graphBuilder.AddFilter(aviSplitter, "Splitter");
        DsError.ThrowExceptionForHR(hr);

        // Have the graph builder construct its appropriate graph automatically
        hr = this.graphBuilder.RenderFile(FileName, null);
        DsError.ThrowExceptionForHR(hr);

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

        // Remove the video renderer filter
        IBaseFilter defaultVideoRenderer = null;
        graphBuilder.FindFilterByName("Video Renderer", out defaultVideoRenderer);
        graphBuilder.RemoveFilter(defaultVideoRenderer);

        // Disconnect anything that is connected
        // to the output of the sample grabber
        IPin iPinSampleGrabberOut = DsFindPin.ByDirection(sampleGrabberFilter, PinDirection.Output, 0);
        IPin iPinVideoIn;
        hr = iPinSampleGrabberOut.ConnectedTo(out iPinVideoIn);

        if (hr == 0)
        {
          // Disconnect the sample grabber output from the attached filters
          hr = iPinVideoIn.Disconnect();
          DsError.ThrowExceptionForHR(hr);

          hr = iPinSampleGrabberOut.Disconnect();
          DsError.ThrowExceptionForHR(hr);
        }
        else
        {
          // Try other way round because automatic renderer could not build
          // graph including the sample grabber
          IPin iPinAVISplitterOut = DsFindPin.ByDirection(aviSplitter, PinDirection.Output, 0);
          IPin iPinAVISplitterIn;
          hr = iPinAVISplitterOut.ConnectedTo(out iPinAVISplitterIn);
          DsError.ThrowExceptionForHR(hr);

          hr = iPinAVISplitterOut.Disconnect();
          DsError.ThrowExceptionForHR(hr);

          hr = iPinAVISplitterIn.Disconnect();
          DsError.ThrowExceptionForHR(hr);

          // Connect the avi splitter output to sample grabber
          IPin iPinSampleGrabberIn = DsFindPin.ByDirection(sampleGrabberFilter, PinDirection.Input, 0);
          hr = graphBuilder.Connect(iPinAVISplitterOut, iPinSampleGrabberIn);
          DsError.ThrowExceptionForHR(hr);
        }

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

        // Get the input pin of the null renderer
        IPin iPinNullRendererIn = DsFindPin.ByDirection(nullrenderer, PinDirection.Input, 0);

        // Connect the sample grabber to the null renderer
        hr = graphBuilder.Connect(iPinSampleGrabberOut, iPinNullRendererIn);
        DsError.ThrowExceptionForHR(hr);

        // Read and cache the image sizes
        SaveSizeInfo(sampleGrabber);

        this.GetFrameStepInterface();
      }
      finally
      {
      }
    }
开发者ID:DeSciL,项目名称:Ogama,代码行数:99,代码来源:VideoFramePusher.cs


示例10: OpenStream

        //
        // Starts playback for the selected stream at the specified time
        //
        int OpenStream(string videopath, double videotime)
        {
            double td;  // store stream duration;
            int hr = 0;

            // animate bt logo
            //   logo_webbrowser.Refresh();

            // cover overlay options with video or not
            // if overlay is active
            ////////if (OverlayButton.Checked) // Overlay button config - Melek
            ////////{
            ////////    VideoPanel.Width = VideoPlayerPanel.Width - OverlayPanel.Width;
            ////////    OverlayBar.Location = new System.Drawing.Point(-1, -1); ;
            ////////    OverlayBar.Text = ">";
            ////////}
            ////////else
            ////////// if overlay is not active
            ////////{
            ////////    VideoPanel.Width = VideoPlayerPanel.Width - OverlayBar.Width;
            ////////    OverlayBar.Location = new System.Drawing.Point(OverlayPanel.Width - OverlayBar.Width - 1, -1); ;
            ////////    OverlayBar.Text = "<";
            ////////}

            filename = videopath;
            try//Melek
            {
                if (filename == string.Empty)
                    return -1;

                // this.graphBuilder = (IGraphBuilder)new FilterGraph();
                this.graphBuilder = (IFilterGraph2)new FilterGraph();

                // We manually add the VMR (video mixer/renderer) filter so that we can set it into "mixing" mode.
                // That is needed so that the VMR will deinterlace before playing back
                VideoMixingRenderer vmr = new VideoMixingRenderer(); //Tom's deinterlace changes
                graphBuilder.AddFilter((IBaseFilter)vmr, "vmr");//Tom's deinterlace changes
                IVMRFilterConfig vmrConfig = vmr as IVMRFilterConfig;//Tom's deinterlace changes
                int nRet = vmrConfig.SetNumberOfStreams(1);//Tom's deinterlace changes

                // BuildVideoGraph(videopath); //No more overlay - Melek
                hr = this.graphBuilder.RenderFile(filename, null);//MELek - instead of calling BuildVideoGraph function call RenderFile function directly
                DsError.ThrowExceptionForHR(hr);//Melek

                // QueryInterface for DirectShow interfaces
                this.mediaControl = (IMediaControl)this.graphBuilder;
                this.mediaEventEx = (IMediaEventEx)this.graphBuilder;
                this.mediaSeeking = (IMediaSeeking)this.graphBuilder;
                this.mediaPosition = (IMediaPosition)this.graphBuilder;

                // Query for video interfaces, which may not be relevant for audio files
                this.videoWindow = this.graphBuilder as IVideoWindow;
                this.basicVideo = this.graphBuilder as IBasicVideo;

                // Query for audio interfaces, which may not be relevant for video-only files
                this.basicAudio = this.graphBuilder as IBasicAudio;

                // Is this an audio-only file (no video component)?
                CheckVisibility();

                // Have the graph signal event via window callbacks for performance
                hr = this.mediaEventEx.SetNotifyWindow(this.Handle, WMGraphNotify, IntPtr.Zero);

                DsError.ThrowExceptionForHR(hr);

                //if (!this.isAudioOnly)
                //{
                // Setup the video window
                hr = this.videoWindow.put_Owner(this.VideoPanel.Handle);

                DsError.ThrowExceptionForHR(hr);

                hr = this.videoWindow.put_WindowStyle(WindowStyle.Child | WindowStyle.ClipSiblings | WindowStyle.ClipChildren);
                DsError.ThrowExceptionForHR(hr);

                hr = InitVideoWindow(1, 1);
                DsError.ThrowExceptionForHR(hr);

                GetFrameStepInterface();
                //}
                //else
                //{
                // Initialize the default player size
                //    hr = InitPlayerWindow();
                //    DsError.ThrowExceptionForHR(hr);

                //EnablePlaybackMenu(true, MediaType.Audio);
                //}

                // Complete window initialization
                //CheckSizeMenu(menuFileSizeNormal);
                //this.isFullScreen = false;
                this.currentPlaybackRate = 1.0;

            #if DEBUG
                rot = new DsROTEntry(this.graphBuilder);
            #endif
//.........这里部分代码省略.........
开发者ID:mguthrie777,项目名称:demo-newstuff,代码行数:101,代码来源:GUI.cs


示例11: GetInterfaces


//.........这里部分代码省略.........
        Log.Info("BDPlayer: Adding filters");

        _vmr9 = new VMR9Util();
        _vmr9.AddVMR9(_graphBuilder);
        _vmr9.Enable(false);

        // Set VideoDecoder and VC1Override before adding filter in graph
        SetVideoDecoder();
        SetVC1Override();

        // Add preferred video filters
        UpdateFilters("Video");

        // Add preferred audio filters
        UpdateFilters("Audio");

        // Let the subtitle engine handle the proper filters
        try
        {
          SubtitleRenderer.GetInstance().AddSubtitleFilter(_graphBuilder);
        }
        catch (Exception e)
        {
          Log.Error(e);
        }
        
        #endregion

        #region PostProcessingEngine Detection

        IPostProcessingEngine postengine = PostProcessingEngine.GetInstance(true);
        if (!postengine.LoadPostProcessing(_graphBuilder))
        {
          PostProcessingEngine.engine = new PostProcessingEngine.DummyEngine();
        }

        #endregion

        #region render BDReader output pins

        Log.Info("BDPlayer: Render BDReader outputs");

        if (_interfaceBDReader != null)
        {
          DirectShowUtil.RenderGraphBuilderOutputPins(_graphBuilder, _interfaceBDReader);
        }
        
        //remove InternalScriptRenderer as it takes subtitle pin
        disableISR();

        //disable Closed Captions!
        disableCC();

        //RemoveAudioR();

        DirectShowUtil.RemoveUnusedFiltersFromGraph(_graphBuilder);

        #endregion

        _mediaCtrl = (IMediaControl)_graphBuilder;
        _mediaEvt = (IMediaEventEx)_graphBuilder;
        _mediaSeeking = (IMediaSeeking)_graphBuilder;

        try
        {
          SubtitleRenderer.GetInstance().SetPlayer(this);
          _dvbSubRenderer = SubtitleRenderer.GetInstance();
        }
        catch (Exception e)
        {
          Log.Error(e);
        }

        _subtitleStream = (Player.TSReaderPlayer.ISubtitleStream)_interfaceBDReader;
        if (_subtitleStream == null)
        {
          Log.Error("BDPlayer: Unable to get ISubtitleStream interface");
        }

        // if only dvb subs are enabled, pass null for ttxtDecoder
        _subSelector = new SubtitleSelector(_subtitleStream, _dvbSubRenderer, null);
        EnableSubtitle = _subtitlesEnabled;

        //Sync Audio Renderer
        SyncAudioRenderer();

        if (!_vmr9.IsVMR9Connected)
        {
          Log.Error("BDPlayer: Failed vmr9 not connected");
          return false;
        }
        _vmr9.SetDeinterlaceMode();
        return true;
      }
      catch (Exception ex)
      {
        Log.Error("BDPlayer: Exception while creating DShow graph {0}", ex.Message);
        return false;
      }
    }
开发者ID:Erls-Corporation,项目名称:MediaPortal-1,代码行数:101,代码来源:BDPlayer.cs


示例12: GetDVDInterfaces


//.........这里部分代码省略.........
                catch (Exception ex)
                {
                    string strEx = ex.Message;
                }

                Guid riid;

                if (_dvdInfo == null)
                {
                    riid = typeof(IDvdInfo2).GUID;
                    hr = _dvdGraph.GetDvdInterface(riid, out comobj);
                    if (hr < 0)
                    {
                        Marshal.ThrowExceptionForHR(hr);
                    }
                    _dvdInfo = (IDvdInfo2)comobj;
                    comobj = null;
                }

                if (_dvdCtrl == null)
                {
                    riid = typeof(IDvdControl2).GUID;
                    hr = _dvdGraph.GetDvdInterface(riid, out comobj);
                    if (hr < 0)
                    {
                        Marshal.ThrowExceptionForHR(hr);
                    }
                    _dvdCtrl = (IDvdControl2)comobj;
                    comobj = null;
                }

                _mediaCtrl = (IMediaControl)_graphBuilder;
                _mediaEvt = (IMediaEventEx)_graphBuilder;
                _basicAudio = _graphBuilder as IBasicAudio;
                _mediaPos = (IMediaPosition)_graphBuilder;
                _mediaSeek = (IMediaSeeking)_graphBuilder;
                _mediaStep = (IVideoFrameStep)_graphBuilder;
                _basicVideo = _graphBuilder as IBasicVideo2;
                _videoWin = _graphBuilder as IVideoWindow;

                // disable Closed Captions!
                IBaseFilter baseFilter;
                _graphBuilder.FindFilterByName("Line 21 Decoder", out baseFilter);
                if (baseFilter == null)
                {
                    _graphBuilder.FindFilterByName("Line21 Decoder", out baseFilter);
                }
                if (baseFilter != null)
                {
                    _line21Decoder = (IAMLine21Decoder)baseFilter;
                    if (_line21Decoder != null)
                    {
                        AMLine21CCState state = AMLine21CCState.Off;
                        hr = _line21Decoder.SetServiceState(state);
                        if (hr == 0)
                        {
                            logger.Info("DVDPlayer:Closed Captions disabled");
                        }
                        else
                        {
                            logger.Info("DVDPlayer:failed 2 disable Closed Captions");
                        }
                    }
                }
                /*
                        // get video window
                        if (_videoWin==null)
                        {
                          riid = typeof( IVideoWindow ).GUID;
                          hr = _dvdGraph.GetDvdInterface( ref riid, out comobj );
                          if( hr < 0 )
                            Marshal.ThrowExceptionForHR( hr );
                          _videoWin = (IVideoWindow) comobj; comobj = null;
                        }
                  */
                // GetFrameStepInterface();

                DirectShowUtil.SetARMode(_graphBuilder, arMode);
                DirectShowUtil.EnableDeInterlace(_graphBuilder);
                //m_ovMgr = new OVTOOLLib.OvMgrClass();
                //m_ovMgr.SetGraph(_graphBuilder);

                return true;
            }
            catch (Exception)
            {

                //MessageBox.Show( this, "Could not get interfaces\r\n" + ee.Message, "DVDPlayer.NET", MessageBoxButtons.OK, MessageBoxIcon.Stop );
                CloseDVDInterfaces();
                return false;
            }
            finally
            {
                if (comobj != null)
                {
                    DirectShowUtil.ReleaseComObject(comobj);
                }
                comobj = null;
            }
        }
开发者ID:andrewjswan,项目名称:mvcentral,代码行数:101,代码来源:Grabber.cs


示例13: StartCapture


//.........这里部分代码省略.........
                // Get the SampleGrabber interface
                sampGrabber = (ISampleGrabber) new SampleGrabber();

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

                // Add the video source
                hr = m_FilterGraph.AddSourceFilter(txtAviFileName.Text, "File Source (Async.)", out capFilter);
                DsError.ThrowExceptionForHR(hr);

                //add AVI Decompressor
                IBaseFilter pAVIDecompressor = (IBaseFilter) new AVIDec();
                hr = m_FilterGraph.AddFilter(pAVIDecompressor, "AVI Decompressor");
                DsError.ThrowExceptionForHR(hr);

                IBaseFilter ffdshow;
                try
                {
                    // Create Decoder filter COM object (ffdshow video decoder)
                    Type comtype = Type.GetTypeFromCLSID(new Guid("{04FE9017-F873-410E-871E-AB91661A4EF7}"));
                    if (comtype == null)
                        throw new NotSupportedException("Creating ffdshow video decoder COM object fails.");
                    object comobj = Activator.CreateInstance(comtype);
                    ffdshow = (IBaseFilter) comobj; // error ocurrs! raised exception
                    comobj = null;
                }
                catch
                {
                    CustomMessageBox.Show("Please install/reinstall ffdshow");
                    return;
                }

                hr = m_FilterGraph.AddFilter(ffdshow, "ffdshow");
                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);


                IBaseFilter vidrender = (IBaseFilter) new VideoRenderer();
                hr = m_FilterGraph.AddFilter(vidrender, "Render");
                DsError.ThrowExceptionForHR(hr);


                IPin captpin = DsFindPin.ByDirection(capFilter, PinDirection.Output, 0);

                IPin ffdpinin = DsFindPin.ByName(ffdshow, "In");

                IPin ffdpinout = DsFindPin.ByName(ffdshow, "Out");

                IPin samppin = DsFindPin.ByName(baseGrabFlt, "Input");

                hr = m_FilterGraph.Connect(captpin, ffdpinin);
                DsError.ThrowExceptionForHR(hr);
                hr = m_FilterGraph.Connect(ffdpinout, samppin);
                DsError.ThrowExceptionForHR(hr);

                FileWriter filewritter = new FileWriter();
                IFileSinkFilter filemux = (IFileSinkFilter) filewritter;
                //filemux.SetFileName("test.avi",);

                //hr = capGraph.RenderStream(null, MediaType.Video, capFilter, null, vidrender);
                // DsError.ThrowExceptionForHR(hr); 

                SaveSizeInfo(sampGrabber);

                // setup buffer
                if (m_handle == IntPtr.Zero)
                    m_handle = Marshal.AllocCoTaskMem(m_stride*m_videoHeight);

                // tell the callback to ignore new images
                m_PictureReady = new ManualResetEvent(false);
                m_bGotOne = false;
                m_bRunning = false;

                timer1 = new Thread(timer);
                timer1.IsBackground = true;
                timer1.Start();

                m_mediaextseek = m_FilterGraph as IAMExtendedSeeking;
                m_mediapos = m_FilterGraph as IMediaPosition;
                m_mediaseek = m_FilterGraph as IMediaSeeking;
                double length = 0;
                m_mediapos.get_Duration(out length);
                trackBar_mediapos.Minimum = 0;
                trackBar_mediapos.Maximum = (int) length;

                Start();
            }
            else
            {
                MessageBox.Show("File does not exist");
            }
        }
开发者ID:duyisu,项目名称:MissionPlanner,代码行数:101,代码来源:OSDVideo.cs


示例14: BuildGraph

        private void BuildGraph()
        {
            int hr;
            try
            {
                lblTotalTime.Text = mvs.PlayTime.ToString();
                TimeSpan tt = TimeSpan.Parse(mvs.PlayTime);
                DateTime dt = new DateTime(tt.Ticks);
                lblTotalTime.Text = String.Format("{0:HH:mm:ss}", dt);

                if (mvs.LocalMedia[0].IsDVD)
                {

                    mediaToPlay = mvs.LocalMedia[0];
                    MediaState mediaState = mediaToPlay.State;
                    if (mediaState == MediaState.NotMounted)
                    {
                        MountResult result = mediaToPlay.Mount();
                    }

                    string videoPath = mediaToPlay.GetVideoPath();

                    if (videoPath != null)
                        FirstPlayDvd(videoPath);
                    else
                      FirstPlayDvd(mvs.LocalMedia[0].File.FullName);
                    // Add delegates for Windowless operations
                    AddHandlers();
                    MainForm_ResizeMove(null, null);

                }
                else
                {
                    _graphBuilder = (IFilterGraph2)new FilterGraph();
                    _rotEntry = new DsROTEntry((IFilterGraph)_graphBuilder);
                    _mediaCtrl = (IMediaControl)_graphBuilder;
                    _mediaSeek = (IMediaSeeking)_graphBuilder;
                    _mediaPos = (IMediaPosition)_graphBuilder;
                    _mediaStep = (IVideoFrameStep)_graphBuilder;
                    _vmr9Filter = (IBaseFilter)new VideoMixingRenderer9();
                    ConfigureVMR9InWindowlessMode();
                    AddHandlers();
                    MainForm_ResizeMove(null, null);
                    hr = _graphBuilder.AddFilter(_vmr9Filter, "Video Mixing Render 9");
                    AddPreferedCodecs(_graphBuilder);
                    DsError.ThrowExceptionForHR(hr);
                    hr = _graphBuilder.RenderFile(mvs.LocalMedia[0].File.FullName, null);
                    DsError.ThrowExceptionForHR(hr);
                }

            }
            catch (Exception e)
            {
                CloseDVDInterfaces();
                logger.ErrorException("An error occured during the graph building : \r\n\r\n",e);
            }
        }
开发者ID:andrewjswan,项目名称:mvcentral,代码行数:57,代码来源:Grabber.cs


示例15: Setup


//.........这里部分代码省略.........
            #endif

            #if false
                // Avi Splitter
                IBaseFilter splitter = (IBaseFilter)Activator.CreateInstance(Type.GetTypeFromCLSID(new Guid(GUID.CLSID_AVISplitter)));
                if (splitter == null)
                    throw new System.IO.IOException();
                this.GraphBuilder.AddFilter(splitter, "Avi Splitter");

                // Avi Decompressor
                IBaseFilter decompressor = (IBaseFilter)Activator.CreateInstance(Type.GetTypeFromCLSID(new Guid(GUID.CLSID_AVIDec)));
                if (decompressor == null)
                    throw new System.IO.IOException();
                this.GraphBuilder.AddFilter(decompressor, "Avi Decompressor");
            #endif

                // サンプルグラバー.
                IBaseFilter grabber = (IBaseFilter)CreateSampleGrabber();
                if (grabber == null)
                    throw new System.IO.IOException();
                this.GraphBuilder.AddFilter(grabber, "SampleGrabber");

                // レンダラー.
                IBaseFilter renderer = (IBaseFilter)Activator.CreateInstance(Type.GetTypeFromCLSID(new Guid(GUID.CLSID_NullRenderer)));
                if (renderer == null)
                    throw new System.IO.IOException();
                this.GraphBuilder.AddFilter(renderer, "Renderer");
                #endregion

                #region ピンの取得.
                IPin capture_out = DSLab.Axi.FindPin(capture, 0, PIN_DIRECTION.PINDIR_OUTPUT);
                IPin grabber_in = DSLab.Axi.FindPin(grabber, 0, PIN_DIRECTION.PINDIR_INPUT);
                IPin grabber_out = DSLab.Axi.FindPin(grabber, 0, PIN_DIRECTION.PINDIR_OUTPUT);
                IPin renderer_in = DSLab.Axi.FindPin(renderer, 0, PIN_DIRECTION.PINDIR_INPUT);
                #endregion

                #region ピンの接続.
                GraphBuilder.Connect(capture_out, grabber_in);
                GraphBuilder.Connect(grabber_out, renderer_in);
                #endregion

                #region 保管: インターフェース.
                CaptureFilter = capture;
                CaptureOutPin = capture_out;
                SampleGrabber = (ISampleGrabber)grabber;
                SampleGrabberInPin = grabber_in;
                SampleGrabberOutPin = grabber_out;
                Renderer = renderer;
                RendererInPin = renderer_in;
                #endregion

                #region 保管: フレームサイズ.
                VIDEOINFOHEADER vinfo = DSLab.Axi.GetVideoInfo(SampleGrabber);
                this.SampleGrabberCB.BitmapInfo = vinfo.bmiHeader;
                this.SampleGrabberCB.FrameSize = new Size(
                    System.Math.Abs(this.SampleGrabberCB.BitmapInfo.biWidth),
                    System.Math.Abs(this.SampleGrabberCB.BitmapInfo.biHeight)
                    );
                #endregion

                #region インタフェースの抽出:
                {
                    DSLab.IGraphBuilder graph = this.GraphBuilder;
                    DSLab.IEnumFilters filters = null;
                    DSLab.IBaseFilter filter = null;
                    int fetched = 0;

                    int hr = graph.EnumFilters(ref filters);
                    while (filters.Next(1, ref filter, ref fetched) == (int)DSLab.HRESULT.S_OK)
                    {
                        if (fetched == 0) break;

                        if (filter is DSLab.IMediaSeeking)
                        {
                            // シーク操作用.
                            Seeking = (DSLab.IMediaSeeking)filter;
                        }
                        else
                        {
                            // フィルタ解放.
                            Marshal.ReleaseComObject(filter);
                            filter = null;
                        }
                    }

                    // 解放.
                    Marshal.ReleaseComObject(filters);
                }
                #endregion

                // DEBUG
            #if DEBUG
                DebugPrint(this.GraphBuilder);
            #endif
            }
            catch (Exception ex)
            {
                throw new DSLab.CxDSException(ex);
            }
        }
开发者ID:cogorou,项目名称:DSLab,代码行数:101,代码来源:CxDSMediaPlayer.cs


示例16: GetInterfaces


//.........这里部分代码省略.........
            graphBuilder.Render(pins[0]);
          }
        }

        #endregion

        // Connect DVB subtitle filter pins in the graph
        if (_mpegDemux != null && enableDvbSubtitles == true)
        {
          IMpeg2Demultiplexer demuxer = _mpegDemux as IMpeg2Demultiplexer;
          hr = demuxer.CreateOutputPin(GetTSMedia(), "Pcr", out _pinPcr);

          if (hr == 0)
          {
            Log.Info("RTSPPlayer:_pinPcr OK");

            IPin pDemuxerPcr = DsFindPin.ByName(_mpegDemux, "Pcr");
            IPin pSubtitlePcr = DsFindPin.ByName(_subtitleFilter, "Pcr");
            hr = graphBuilder.Connect(pDemuxerPcr, pSubtitlePcr);
          }
          else
          {
            Log.Info("RTSPPlayer:Failed to create _pinPcr in demuxer:{0:X}", hr);
          }

          hr = demuxer.CreateOutputPin(GetTSMedia(), "Subtitle", out _pinSubtitle);
          if (hr == 0)
          {
            Log.Info("RTSPPlayer:_pinSubtitle OK");

            IPin pDemuxerSubtitle = DsFindPin.ByName(_mpegDemux, "Subtitle");
            IPin pSubtitle = DsFindPin.ByName(_subtitleFilter, "In");
            hr = graphBuilder.Connect(pDemuxerSubtitle, pSubtitle);
          }
          else
          {
            Log.Info("RTSPPlayer:Failed to create _pinSubtitle in demuxer:{0:X}", hr);
          }

          hr = demuxer.CreateOutputPin(GetTSMedia(), "PMT", out _pinPMT);
          if (hr == 0)
          {
            Log.Info("RTSPPlayer:_pinPMT OK");

            IPin pDemuxerSubtitle = DsFindPin.ByName(_mpegDemux, "PMT");
            IPin pSubtitle = DsFindPin.ByName(_subtitleFilter, "PMT");
            hr = graphBuilder.Connect(pDemuxerSubtitle, pSubtitle);
          }
          else
          {
            Log.Info("RTSPPlayer:Failed to create _pinPMT in demuxer:{0:X}", hr);
          }
        }


        if (IsRadio == false)
        {
          if (!VMR9Util.g_vmr9.IsVMR9Connected)
          {
            //VMR9 is not supported, switch to overlay
            Log.Info("RTSPPlayer: vmr9 not connected");
            _mediaCtrl = null;
            Cleanup();
            return false;
          }
          VMR9Util.g_vmr9.SetDeinterlaceMode();
        }

        _mediaCtrl = (IMediaControl)graphBuilder;
        mediaEvt = (IMediaEventEx)graphBuilder;
        _mediaSeeking = (IMediaSeeking)graphBuilder;
        mediaPos = (IMediaPosition)graphBuilder;
        basicAudio = graphBuilder as IBasicAudio;
        //DirectShowUtil.SetARMode(graphBuilder,AspectRatioMode.Stretched);
        DirectShowUtil.EnableDeInterlace(graphBuilder);
        if (VMR9Util.g_vmr9 != null)
        {
          m_iVideoWidth = VMR9Util.g_vmr9.VideoWidth;
          m_iVideoHeight = VMR9Util.g_vmr9.VideoHeight;
        }
        if (audioRendererFilter != null)
        {
          Log.Info("RTSPPlayer9:set reference clock");
          IMediaFilter mp = graphBuilder as IMediaFilter;
          IReferenceClock clock = audioRendererFilter as IReferenceClock;
          hr = mp.SetSyncSource(null);
          hr = mp.SetSyncSource(clock);
          Log.Info("RTSPPlayer9:set reference clock:{0:X}", hr);
        }
        Log.Info("RTSPPlayer: graph build successfull");
        return true;
      }
      catch (Exception ex)
      {
        Error.SetError("Unable to play movie", "Unable build graph for VMR9");
        Log.Error("RTSPPlayer:exception while creating DShow graph {0} {1}", ex.Message, ex.StackTrace);
        CloseInterfaces();
        return false;
      }
    }
开发者ID:MediaPortal,项目名称:MediaPortal-1,代码行数:101,代码来源:RTSPPlayer.cs


示例17: PlayMovieInWindow

        private void PlayMovieInWindow(string filename)
        {
            int hr = 0;

              if (filename == string.Empty)
            return;

              this.graphBuilder = (IGraphBuilder) new FilterGraph();

              // Have the graph builder construct its the appropriate graph automatically
              hr = this.graphBuilder.RenderFile(filename, null);
              DsError.ThrowExceptionForHR(hr);

              // QueryInterface for DirectShow interfaces
              this.mediaControl = (IMediaControl) this.graphBuilder;
              this.mediaEventEx = (IMediaEventEx) this.graphBuilder;
              this.mediaSeeking = (IMediaSeeking) this.graphBuilder;
              this.mediaPosition = (IMediaPosition) this.graphBuilder;

              // Query for video interfaces, which may not be relevant for audio files
              this.videoWindow = this.graphBuilder as IVideoWindow;
              this.basicVideo = this.graphBuilder as IBasicVideo;

              // Query for audio interfaces, which may not be relevant for video-only files
              this.basicAudio = this.graphBuilder as IBasicAudio;

              // Is this an audio-only file (no video component)?
              CheckVisibility();

              // Have the graph signal event via window callbacks for performance
              hr = this.mediaEventEx.SetNotifyWindow(this.Handle, WMGraphNotify, IntPtr.Zero);
              DsError.ThrowExceptionForHR(hr);

              if (!this.isAudioOnly)
              {
            // Setup the video window
            hr = this.videoWindow.put_Owner(this.Handle);
            DsError.ThrowExceptionForHR(hr);

            hr = this.videoWindow.put_WindowStyle(WindowStyle.Child | WindowStyle.ClipSiblings | WindowStyle.ClipChildren);
            DsError.ThrowExceptionForHR(hr);

            hr = InitVideoWindow(1, 1);
            DsError.ThrowExceptionForHR(hr);

            GetFrameStepInterface();
              }
              else
              {
            // Initialize the default player size and enable playback menu items
            hr = InitPlayerWindow();
            DsError.ThrowExceptionForHR(hr);

            EnablePlaybackMenu(true, M 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IMediaService类代码示例发布时间:2022-05-24
下一篇:
C# IMediaSample类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap