예제 #1
0
        /// <summary>
        /// Releases unmanaged and - optionally - managed resources.
        /// </summary>
        /// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
        protected void Dispose(bool disposing)
        {
            GC.SuppressFinalize(this);

            if (disposing)
            {
                if (_disposeStream && _stream != null)
                {
                    _stream.Dispose();
                    _stream = null;
                }

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

                if (_ffmpegStream != null)
                {
                    _ffmpegStream.Dispose();
                    _ffmpegStream = null;
                }
            }
        }
예제 #2
0
        private void InitializeWithStream(Stream stream, bool disposeStream)
        {
            _stream        = stream;
            _disposeStream = disposeStream;

            _ffmpegStream  = new FfmpegStream(stream);
            _formatContext = new AvFormatContext(_ffmpegStream);
            Initialize();
        }
예제 #3
0
        public unsafe AvFormatContext(FfmpegStream stream)
        {
            _formatContext = FfmpegCalls.AvformatAllocContext();
            fixed(AVFormatContext **pformatContext = &_formatContext)
            {
                FfmpegCalls.AvformatOpenInput(pformatContext, stream.AvioContext);
            }

            Initialize();
        }
예제 #4
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="FfmpegDecoder" /> class based on a <see cref="Stream" />.
        /// </summary>
        /// <param name="stream">The stream.</param>
        /// <exception cref="FfmpegException">Any ffmpeg error.</exception>
        /// <exception cref="System.ArgumentNullException">stream</exception>
        /// <exception cref="ArgumentException">Stream is not readable.</exception>
        /// <exception cref="System.OutOfMemoryException">Could not allocate FormatContext.</exception>
        /// <exception cref="System.NotSupportedException">
        ///     DBL format is not supported.
        ///     or
        ///     Audio Sample Format not supported.
        /// </exception>
        public FfmpegDecoder(Stream stream)
        {
            if (stream == null)
            {
                throw new ArgumentNullException("stream");
            }

            _ffmpegStream  = new FfmpegStream(stream);
            _formatContext = new AvFormatContext(_ffmpegStream);
            Initialize();
        }