Пример #1
0
        /// <summary>
        ///     Disposes the <see cref="MediaFoundationEncoder" />.
        /// </summary>
        /// <param name="disposing">
        ///     True to release both managed and unmanaged resources; false to release only unmanaged
        ///     resources.
        /// </param>
        protected virtual void Dispose(bool disposing)
        {
            if (!_disposed)
            {
                if (_sinkWriter != null && !_sinkWriter.IsDisposed)
                {
                    //thanks to martin48 (and naudio??) for providing the following source code (see http://cscore.codeplex.com/discussions/574280):
                    SinkWriterStatistics statistics = _sinkWriter.GetStatistics(_streamIndex);
                    if (statistics.DwByteCountQueued > 0 || statistics.QwNumSamplesReceived > 0)
                    {
                        _sinkWriter.Finalize();
                    }

                    _sinkWriter.Dispose();
                    _sinkWriter = null;
                }
                if (_targetStream != null)
                {
                    _targetStream.Flush();
                    _targetStream.Dispose();
                    _targetStream = null;
                }
            }
            _disposed = true;
        }
Пример #2
0
        public SinkWriterStatistics GetStatistics(int dwStreamIndex)
        {
            SinkWriterStatistics statsRef = new SinkWriterStatistics();

            GetStatistics(dwStreamIndex, out statsRef);
            return(statsRef);
        }