Пример #1
0
        public void Dispose()
        {
            if (_hik != null)
            {
                _hik.StreamEvent -= onHikStream;
                _hik.Dispose();
                _hik = null;
            }

            if (_renderSource != null)
            {
                _renderSource.ImageSourceChanged -= onImageSource;
                _renderSource.Dispose();
                _renderSource = null;
            }

            if (_decoder != null)
            {
                _decoder.Dispose();
                _decoder = null;
            }

            if (_rtsp != null)
            {
                _rtsp.Dispose();
                _rtsp = null;
            }
        }
Пример #2
0
        public void Dispose()
        {
            if (isDisposed)
            {
                return;
            }

            isDisposed = true;

            videoContextHandle?.Dispose();
            videoDecoderHandle?.Dispose();
            decoderConfigHandle?.Dispose();
            decoderOuputViewsHandle?.Dispose();

#if XENKO_GRAPHICS_API_DIRECT3D11
            videoHardwareDecoder?.Dispose();
            videoHardwareDecoderView?.Dispose();
#endif

            DecoderOutputTexture?.Dispose();
            DecoderOutputTexture = null;

            var pHWDeviceContextLocal = pHWDeviceContext;
            ffmpeg.av_buffer_unref(&pHWDeviceContextLocal);

            var pAVCodecContextLocal = pAVCodecContext;
            ffmpeg.avcodec_close(pAVCodecContextLocal);
            ffmpeg.avcodec_free_context(&pAVCodecContextLocal);
        }
Пример #3
0
        private void SetupPlayer()
        {
            if (_decoder != null)
            {
                _decoder.Stop();
                _decoder.ClearBuffer();
                _decoder.Dispose();
                _decoder = null;
            }

            string file = "";

            Dispatcher.Invoke(() => file = txtFileName.Text);

            _decoder = new VideoDecoder();
            _decoder.Open(file);
            _decoder.PlayerOutputWidth  = _decoder.VideoInfo.Width;
            _decoder.PlayerOutputHeight = _decoder.VideoInfo.Height;

            Dispatcher.Invoke(() =>
            {
                sliderTime.Minimum = 0;
                sliderTime.Maximum = _decoder.VideoInfo.TotalFrames - 1;
            });

            if (iterator == null)
            {
                iterator = new FrameIterator(_decoder.VideoInfo.TotalFrames,
                                             templateView.TemplatePaths.Keys.Count,
                                             AppSettings.Default.BurstSize
                                             );

                var startFrame = (int)Math.Round(AppSettings.Default.StartTime * _decoder.VideoInfo.FPS);
                var endFrame   = (int)Math.Round(AppSettings.Default.EndTime * _decoder.VideoInfo.FPS);

                if (AppSettings.Default.UseRandom)
                {
                    iterator.InitRandomSequence(
                        AppSettings.Default.MaxFrames,
                        Math.Max(0, startFrame),
                        Math.Min(_decoder.VideoInfo.TotalFrames, endFrame) - 1,
                        AppSettings.Default.UseSeed ? AppSettings.Default.Seed : (int?)null
                        );
                }
                else
                {
                    iterator.InitLinearSequence(
                        AppSettings.Default.EveryNth,
                        Math.Max(0, startFrame),
                        Math.Min(_decoder.VideoInfo.TotalFrames - 1, endFrame)
                        );
                }
            }

            _decoder.SeekTo(iterator.BurstBeginFrameIndex);
            _decoder.Start();
            _decoder.FrameDecoder.FrameBufferCapacity  = 1;
            _decoder.FrameDecoder.MinimumWorkingFrames = 1;
        }
Пример #4
0
 public void Release()
 {
     if (_decoder != null)
     {
         _decoder.Dispose();
     }
     _decoder = null;
 }
Пример #5
0
 protected override void DisposeOverride()
 {
     if (_videoDecoder != null)
     {
         _videoDecoder.Dispose();
     }
     if (_videoConverter != null)
     {
         _videoConverter.Dispose();
     }
 }
Пример #6
0
 private void stop()
 {
     VideoInfo.IsEnabled = true;
     disposeHikSource();
     disposeHikDecoder();
     if (_decoder != null)
     {
         _decoder.Dispose();
     }
     _decoder = null;
     disposeRenderSource();
     ImageSrc = null;
 }
Пример #7
0
 /// <summary>
 /// Shut down the VideoTexture.
 /// </summary>
 public void Dispose(bool isDisposing)
 {
     State = PlaybackState.Exiting;
     if (vd != null)
     {
         vd.Dispose();
     }
     if (videoTextures != null)
     {
         foreach (pTexture t in videoTextures)
         {
             if (t != null)
             {
                 t.Dispose();
             }
         }
     }
 }