private void StopDXRendering(VideoStreamInfo streamInfo)
        {
            streamInfo.IsRunning = false;

            foreach (D3DImage image in streamInfo.Images)
            {
                image.Lock();
                image.SetBackBuffer(D3DResourceType.IDirect3DSurface9, IntPtr.Zero);
                image.Unlock();
            }

            streamer.StopStream(streamInfo.Index);
            streamInfo.SetFps(0);
        }
        private void SampleReadyCallback(int index, int fps)
        {
            VideoStreamInfo streamInfo = _streamInfoByIndex[index];

            if (!streamInfo.IsRunning)
            {
                return;
            }

            streamer.Next(index);
            streamInfo.SetFps(fps);

            streamInfo.IsNewFrameReady = true;
        }
        private void StartDXRendering(VideoStreamInfo streamInfo)
        {
            IntPtr scene;
            int    videoWidth, videoHeight;

            if (streamInfo is WebcamStreamInfo)
            {
                bool isHwEnabled = false;
                streamInfo.Index = streamer.StartStream(((WebcamStreamInfo)streamInfo).WebcamIndex, out videoWidth, out videoHeight, out scene, out isHwEnabled, _sampleReadyCallback);
                mainStreamFrameSizeLabel.Content = isHwEnabled ?
                                                   $"{videoWidth} x {videoHeight} (HWA!)" :
                                                   $"{videoWidth} x {videoHeight}";
            }
            else if (streamInfo is VideoFileStreamInfo)
            {
                streamInfo.Index = streamer.StartStream(((VideoFileStreamInfo)streamInfo).Source, out videoWidth, out videoHeight, out scene, _sampleReadyCallback);
            }
            else
            {
                throw new ApplicationException();
            }

            _streamInfoByIndex[streamInfo.Index] = streamInfo;

            streamInfo.Width  = videoWidth;
            streamInfo.Height = videoHeight;

            foreach (D3DImage image in streamInfo.Images)
            {
                image.Lock();
                image.SetBackBuffer(D3DResourceType.IDirect3DSurface9, scene, true);
                image.Unlock();
            }

            streamInfo.IsRunning = true;
        }