Exemplo n.º 1
0
        async Task close(CancellationTokenSource interruptIOTokenSource, Task openTask)
        {
            // cancel any running open operation
            if (interruptIOTokenSource != null)
            {
                interruptIOTokenSource.Cancel();
                try
                {
                    if (!openTask.IsCompleted)
                    {
                        await openTask;
                    }
                }
                catch (OperationCanceledException)
                {
                }
            }

            if (VideoState == VideoState.CLOSED)
            {
                return;
            }

            VideoState = VideoState.CLOSED;

            videoDecoder.FrameQueue.setState(FrameQueue.FrameQueueState.CLOSE,
                                             FrameQueue.FrameQueueState.CLOSE, FrameQueue.FrameQueueState.CLOSE);

            demuxPacketsCancellationTokenSource.Cancel();

            await Task.WhenAll(demuxPacketsTask);

            videoDecoder.close();

            VideoClock = 0;
            AudioClock = 0;

            audioPts = 0;
            videoPts = 0;

            videoPtsDrift = 0;

            DurationSeconds = 0;
            PositionSeconds = 0;

            NrFramesDropped  = 0;
            NrFramesRendered = 0;

            VideoLocation = "";
        }