Unosquare.FFmpegMediaElement.FFmpegMediaFrameCache.RemoveFirst C# (CSharp) Method

RemoveFirst() public method

Removes the first frame and releases it.
public RemoveFirst ( ) : void
return void
        public void RemoveFirst()
        {
            lock (SyncLock)
            {
                if (Frames.Count == 0)
                    return;

                try
                {
                    var index = 0;
                    var frame = Frames[index];
                    Frames.RemoveAt(index);
                    frame.EnqueueRelease();
                }
                finally
                {
                    RecomputeProperties();
                }
            }
        }

Usage Example

Beispiel #1
0
        private void InternalFillFramesCache(TimeSpan timeout)
        {
            var startTime = DateTime.UtcNow;

            while (LeadingFramesCache.IsFull == false && IsAtEndOfStream == false)
            {
                if (DateTime.UtcNow.Subtract(startTime).Ticks > timeout.Ticks)
                {
                    ErrorOccurredCallback(this, new MediaPlaybackException(MediaPlaybackErrorSources.InternalFillFamesCache, MediaPlaybackErrorCode.FillFramesFailed,
                                                                           string.Format("Fill Frames Cache = Failed to fill cache in {0}; Leading Frames: {1}; Lagging Frames: {2}",
                                                                                         timeout, LeadingFramesCache.Count, LaggingFramesCache.Count)));

                    return;
                }

                var frame = this.PullMediaFrame();
                if (frame != null)
                {
                    // reset the start time because we are in fact getting frames.
                    startTime = DateTime.UtcNow;

                    if (frame.Type == LeadingFramesCache.Type)
                    {
                        LeadingFramesCache.Add(frame);
                    }
                    else if (frame.Type == LaggingFramesCache.Type)
                    {
                        if (LaggingFramesCache.IsFull)
                        {
                            LaggingFramesCache.RemoveFirst();
                        }

                        LaggingFramesCache.Add(frame);
                    }
                }
            }
        }
All Usage Examples Of Unosquare.FFmpegMediaElement.FFmpegMediaFrameCache::RemoveFirst