/// <summary>
        /// Remove all frames captured before the given capture time. They will not be encoded.
        /// </summary>
        public void WipeBufferUntil(double AbandonTime)
        {
            lock (this) {
                lock (WaitingCaptures) {
                    while (WaitingCaptures.DataAvailable(this))
                    {
                        var ti = WaitingCaptures.Peek(this);
                        if (ti != null && ti.Seconds < AbandonTime)
                        {
                            WaitingCaptures.Dequeue(this);
                        }
                        else
                        {
                            break;
                        }
                    }
                }
            }

            lock (WaitingFrames) {
                while (WaitingFrames.Count > 0 && WaitingFrames[0].Seconds < AbandonTime)
                {
                    WaitingFrames.RemoveAt(0);
                }
            }

            GC.Collect();
        }
Пример #2
0
        /// <summary>
        /// Respond to capture event. Frame and timings are passed to each buffer.
        /// </summary>
        public void HandleCapturedFrame(object sender, VideoDataEventArgs e)
        {
            // Run plug-ins, convert to YUV, then send YUV buffers to individual buffers for scaling.
            if (e.Frame != null)
            {
                try {
                    if (ProcessorQueue != null)                       // process the source image
                    {
                        foreach (var item in ProcessorQueue)
                        {
                            item.ProcessFrame(e.Frame, e.CaptureTime);
                        }
                    }
                } catch { }

                var ti = new TimedImage(e.CaptureTime, e.Frame.Width, e.Frame.Height);
                ResampleBuffer(e.Frame, ti);

                WaitingCaptures.Enqueue(ti);

                foreach (var buffer in this)
                {
                    if (buffer.WaitingCaptures != WaitingCaptures)
                    {
                        buffer.WaitingCaptures = WaitingCaptures;
                    }
                }
            }
        }