コード例 #1
0
ファイル: SegmentStream.cs プロジェクト: okankilic/LisconVT
        protected override void Dispose(bool disposing)
        {
            //Does nothing base.Dispose(disposing);

            //If disposing
            if (disposing)
            {
                IsDisposed = true;
                //Calls Close virtual (Calls Dispose(true) and GC.SuppressFinalize(this))
                //base.Dispose();

                //Clear memory
                Clear();

                m_Position = m_Cursor = -1;

                //Handled with free...
                if (false.Equals(IDisposedExtensions.IsNullOrDisposed(WorkingSegment)))
                {
                    BaseDisposable.SetShouldDispose(WorkingSegment, true, true);

                    WorkingSegment = null;
                }
            }
        }
コード例 #2
0
ファイル: JitterBuffer.cs プロジェクト: wangweinjcn/RtspMedia
        //Remove with timestamp start and end

        /// <summary>
        /// Clears all contained frames and optionally disposes all contained frames when removed.
        /// </summary>
        /// <param name="disposeFrames"></param>
        public void Clear(bool disposeFrames = true)
        {
            int[] keys = System.Linq.Enumerable.ToArray(Frames.Keys);

            int Key;

            //Store the frames at the key
            System.Collections.Generic.IEnumerable <RtpFrame> frames;

            //Could perform in parallel, would need frames local.
            //System.Linq.ParallelEnumerable.ForAll(keys, () => { });

            //Enumerate an array of contained keys
            for (int i = 0, e = keys.Length; i < e; ++i)
            {
                //Get the key
                Key = keys[i];

                //if removed from the ConcurrentThesaurus
                if (Frames.Remove(ref Key, out frames))
                {
                    //if we need to dispose the frames then Loop the frames contined at the key
                    if (disposeFrames)
                    {
                        foreach (RtpFrame frame in frames)
                        {
                            //Set ShouldDispose through the base class.
                            BaseDisposable.SetShouldDispose(frame, true, true);

                            //Dispose the frame (already done with above call)
                            frame.Dispose();
                        }
                    }
                }
            }
        }