Exemplo n.º 1
0
        public void Dispose()
        {
            if (!IsDisposed)
            {
                DecoderToken.Cancel();
                DecoderTask.Wait();
                DecoderTask.Dispose();

                InputCaptureHandler.Dispose();
                OutputCaptureHandler.Dispose();
                VideoDecoder.Dispose();
                WorkingData.Clear();
                Instance = null;

                IsDisposed = true;
            }
        }
Exemplo n.º 2
0
        public Decoder(NetworkStream inputStream, Vector2 resolution, int framerate = 25, int quality = 0, int bitrate = 1300000)
        {
            Resolution = resolution;
            Framerate  = framerate;
            Quality    = quality;
            Bitrate    = bitrate;
            Instance   = MMALStandalone.Instance;

            InputCaptureHandler  = new SharpInputHandler(inputStream, Decoder_FrameReceived);
            OutputCaptureHandler = new SharpOutputHandler(Decoder_FrameDecoded);
            VideoDecoder         = new MMALVideoDecoder();

            MMALPortConfig inputPortConfig  = new MMALPortConfig(MMALEncoding.H264, MMALEncoding.I420, (int)Resolution.X, (int)Resolution.Y, Framerate, Quality, Bitrate, true, null);
            MMALPortConfig outputPortConfig = new MMALPortConfig(MMALEncoding.RGB16, MMALEncoding.RGB16, (int)Resolution.X, (int)Resolution.Y, Framerate, Quality, Bitrate, true, null);

            // Create our component pipeline.
            VideoDecoder.ConfigureInputPort(inputPortConfig, InputCaptureHandler).ConfigureOutputPort <FileEncodeOutputPort>(0, outputPortConfig, OutputCaptureHandler);

            DecoderToken = new CancellationTokenSource();
            DecoderTask  = Instance.ProcessAsync(VideoDecoder, DecoderToken.Token).ContinueWith(Decoder_ProcessedFinished);
        }