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


C# IMediaSeeking类代码示例

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


IMediaSeeking类属于命名空间,在下文中一共展示了IMediaSeeking类的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: 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: CloseInterfaces

        private void CloseInterfaces()
        {
            int hr = 0;

              try
              {
            lock(this)
            {
              // Relinquish ownership (IMPORTANT!) after hiding video window
              if (!this.isAudioOnly)
              {
            hr = this.videoWindow.put_Visible(OABool.False);
            DsError.ThrowExceptionForHR(hr);
            hr = this.videoWindow.put_Owner(IntPtr.Zero);
            DsError.ThrowExceptionForHR(hr);
              }

              if (this.mediaEventEx != null)
              {
            hr = this.mediaEventEx.SetNotifyWindow(IntPtr.Zero, 0, IntPtr.Zero);
            DsError.ThrowExceptionForHR(hr);
              }

            #if DEBUG
              if (rot != null)
              {
            rot.Dispose();
            rot = null;
              }
            #endif
              // Release and zero DirectShow interfaces
              if (this.mediaEventEx != null)
            this.mediaEventEx = null;
              if (this.mediaSeeking != null)
            this.mediaSeeking = null;
              if (this.mediaPosition != null)
            this.mediaPosition = null;
              if (this.mediaControl != null)
            this.mediaControl = null;
              if (this.basicAudio != null)
            this.basicAudio = null;
              if (this.basicVideo != null)
            this.basicVideo = null;
              if (this.videoWindow != null)
            this.videoWindow = null;
              if (this.frameStep != null)
            this.frameStep = null;
              if (this.graphBuilder != null)
            Marshal.ReleaseComObject(this.graphBuilder); this.graphBuilder = null;

              GC.Collect();
            }
              }
              catch
              {
              }
        }
开发者ID:coolsula,项目名称:vidplaycorder,代码行数:57,代码来源:MainForm.cs

示例13: Dispose

        /// <summary>
        /// 解放
        /// </summary>
        public virtual void Dispose()
        {
            try
            {
                Stop();
            }
            catch (Exception)
            {
            }

            SampleGrabberCB.FrameSize = new Size(0, 0);
            SampleGrabberCB.Notify -= SampleGrabberCB_Notify;

            CaptureFilter = null;
            CaptureOutPin = null;
            SampleGrabber = null;
            SampleGrabberInPin = null;
            SampleGrabberOutPin = null;
            Renderer = null;
            RendererInPin = null;

            if (Seeking != null)
                Marshal.ReleaseComObject(Seeking);
            Seeking = null;

            if (GraphBuilder != null)
                Marshal.ReleaseComObject(GraphBuilder);
            GraphBuilder = null;
        }
开发者ID:cogorou,项目名称:DSLab,代码行数:32,代码来源:CxDSMediaPlayer.cs

示例14: CloseInterfaces

    /// <summary> do cleanup and release DirectShow. </summary>
    protected void CloseInterfaces()
    {
      if (_graphBuilder == null)
      {
        return;
      }
      int hr;
      Log.Debug("BDPlayer: Cleanup DShow graph {0}", GUIGraphicsContext.InVmr9Render);
      try
      {
        BDOSDRenderer.Release();
        
        if (_mediaCtrl != null)
        {
          int counter = 0;
          FilterState state;
          hr = _mediaCtrl.Stop();
          hr = _mediaCtrl.GetState(10, out state);
          while (state != FilterState.Stopped || GUIGraphicsContext.InVmr9Render)
          {
            Thread.Sleep(100);
            hr = _mediaCtrl.GetState(10, out state);
            counter++;
            if (counter >= 30)
            {
              if (state != FilterState.Stopped)
                Log.Error("BDPlayer: graph still running");
              if (GUIGraphicsContext.InVmr9Render)
                Log.Error("BDPlayer: in renderer");
              break;
            }
          }
          _mediaCtrl = null;
        }

        if (_vmr9 != null)
        {
          _vmr9.Enable(false);
        }

        if (_mediaEvt != null)
        {
          hr = _mediaEvt.SetNotifyWindow(IntPtr.Zero, WM_GRAPHNOTIFY, IntPtr.Zero);
          _mediaEvt = null;
        }

        _videoWin = _graphBuilder as IVideoWindow;
        if (_videoWin != null)
        {
          hr = _videoWin.put_Visible(OABool.False);
          hr = _videoWin.put_Owner(IntPtr.Zero);
          _videoWin = null;
        }

        _mediaSeeking = null;
        _basicAudio = null;
        _basicVideo = null;
        _ireader = null;

        #region Cleanup Sebastiii

        if (VideoCodec != null)
        {
          DirectShowUtil.ReleaseComObject(VideoCodec, 5000);
          VideoCodec = null;
          Log.Info("BDPlayer: Cleanup VideoCodec");
        }

        if (AudioCodec != null)
        {
          DirectShowUtil.ReleaseComObject(AudioCodec, 5000);
          AudioCodec = null;
          Log.Info("BDPlayer: Cleanup AudioCodec");
        }

        if (_audioRendererFilter != null)
        {
          while (DirectShowUtil.ReleaseComObject(_audioRendererFilter) > 0) ;
          _audioRendererFilter = null;
          Log.Info("BDPlayer: Cleanup AudioRenderer");
        }

        //Test to ReleaseComObject from PostProcessFilter list objects.
        if (PostProcessFilterVideo.Count > 0)
        {
          foreach (var ppFilter in PostProcessFilterVideo)
          {
            if (ppFilter.Value != null) DirectShowUtil.ReleaseComObject(ppFilter.Value, 5000);
          }
          PostProcessFilterVideo.Clear();
          Log.Info("BDPlayer: Cleanup PostProcessVideo");
        }

        //Test to ReleaseComObject from PostProcessFilter list objects.
        if (PostProcessFilterAudio.Count > 0)
        {
          foreach (var ppFilter in PostProcessFilterAudio)
          {
            if (ppFilter.Value != null) DirectShowUtil.ReleaseComObject(ppFilter.Value, 5000);
//.........这里部分代码省略.........
开发者ID:Erls-Corporation,项目名称:MediaPortal-1,代码行数:101,代码来源:BDPlayer.cs

示例15: Cleanup

    private void Cleanup()
    {
      if (graphBuilder == null)
      {
        return;
      }
      int hr;
      Log.Info("RTSPPlayer:cleanup DShow graph");
      try
      {
        if (_mediaCtrl != null)
        {
          int counter = 0;
          FilterState state;
          hr = _mediaCtrl.Stop();
          hr = _mediaCtrl.GetState(10, out state);
          while (state != FilterState.Stopped || GUIGraphicsContext.InVmr9Render)
          {
            Thread.Sleep(100);
            hr = _mediaCtrl.GetState(10, out state);
            counter++;
            if (counter >= 30)
            {
              if (state != FilterState.Stopped)
                Log.Error("RTSPPlayer: graph still running");
              if (GUIGraphicsContext.InVmr9Render)
                Log.Error("RTSPPlayer: in renderer");
              break;
            }
          }
          _mediaCtrl = null;
        }

        if (Vmr9 != null)
        {
          Vmr9.Enable(false);
        }

        if (mediaEvt != null)
        {
          hr = mediaEvt.SetNotifyWindow(IntPtr.Zero, WM_GRAPHNOTIFY, IntPtr.Zero);
          mediaEvt = null;
        }

        videoWin = graphBuilder as IVideoWindow;
        if (videoWin != null)
        {
          hr = videoWin.put_Visible(OABool.False);
          hr = videoWin.put_Owner(IntPtr.Zero);
          videoWin = null;
        }

        _mediaSeeking = null;
        mediaPos = null;
        basicAudio = null;
        basicVideo = null;
        videoWin = null;
        SubEngine.GetInstance().FreeSubtitles();

        if (graphBuilder != null)
        {
          DirectShowUtil.RemoveFilters(graphBuilder);
          if (_rotEntry != null)
          {
            _rotEntry.SafeDispose();
            _rotEntry = null;
          }
          DirectShowUtil.ReleaseComObject(graphBuilder);
          graphBuilder = null;
        }

        if (Vmr9 != null)
        {
          Vmr9.SafeDispose();
          Vmr9 = null;
        }

        GUIGraphicsContext.form.Invalidate(true);
        _state = PlayState.Init;

        if (_mpegDemux != null)
        {
          Log.Info("cleanup mpegdemux");
          while ((hr = DirectShowUtil.ReleaseComObject(_mpegDemux)) > 0)
          {
            ;
          }
          _mpegDemux = null;
        }
        if (_rtspSource != null)
        {
          Log.Info("cleanup _rtspSource");
          while ((hr = DirectShowUtil.ReleaseComObject(_rtspSource)) > 0)
          {
            ;
          }
          _rtspSource = null;
        }
        if (_subtitleFilter != null)
        {
//.........这里部分代码省略.........
开发者ID:hkjensen,项目名称:MediaPortal-1,代码行数:101,代码来源:RTSPPlayer.cs


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