Exemplo n.º 1
0
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                RemoveObservers();
                if (_session != null)
                {
                    if (_session.Running)
                    {
                        _session.StopRunning();
                    }

                    PreviewLayer.Session = null;

                    if (_videoDeviceInput != null)
                    {
                        _session.RemoveInput(_videoDeviceInput);
                        _videoDeviceInput.Dispose();
                        _videoDeviceInput = null;
                    }

                    if (_movieFileOutput != null)
                    {
                        _session.RemoveOutput(_movieFileOutput);
                        _movieFileOutput.Dispose();
                        _movieFileOutput = null;
                    }

                    if (_stillImageOutput != null)
                    {
                        _session.RemoveOutput(_stillImageOutput);
                        _stillImageOutput.Dispose();
                        _stillImageOutput = null;
                    }

                    _session.Dispose();
                }
            }

            base.Dispose(disposing);
        }