Beispiel #1
0
 public bool Contains(long _timestamp)
 {
     lock (m_Locker)
     {
         if (m_Segment.Wrapped)
         {
             bool postWrap = _timestamp >= m_WorkingZone.Start && _timestamp <= m_Segment.End;
             bool preWrap  = _timestamp >= m_Segment.Start && _timestamp <= m_WorkingZone.End;
             return(postWrap || preWrap);
         }
         else
         {
             return(m_Segment.Contains(_timestamp));
         }
     }
 }
Beispiel #2
0
        /// <summary>
        /// Remove all items that are outside the working zone.
        /// </summary>
        public void PurgeOutsiders()
        {
            lock (m_Locker)
            {
                log.Debug("Purging Outsiders in PreBuffer.");
                int removedAtLeft = 0;
                foreach (int i in SortedFrames())
                {
                    if (m_WorkingZone.Contains(m_Frames[i].Timestamp))
                    {
                        continue;
                    }

                    if (m_Frames[i].Timestamp < m_WorkingZone.Start)
                    {
                        removedAtLeft++;
                    }

                    DisposeFrame(m_Frames[i]);
                    m_Frames[i] = null;

                    if (i == m_CurrentIndex)
                    {
                        m_CurrentIndex = -1;
                    }
                }

                if (m_CurrentIndex >= removedAtLeft)
                {
                    m_CurrentIndex -= removedAtLeft;
                }

                m_CurrentIndex = Math.Max(0, m_CurrentIndex);
                m_Current      = m_Frames[m_CurrentIndex];

                m_Frames.RemoveAll(frame => object.ReferenceEquals(null, frame));
                UpdateSegment();

                Monitor.Pulse(m_Locker);
            }
        }
Beispiel #3
0
        /// <summary>
        /// Remove all items that are outside the working zone.
        /// </summary>
        public void ReduceWorkingZone(VideoSection _newZone)
        {
            m_WorkingZone = _newZone;

            int removedAtLeft = 0;

            for (int i = 0; i < m_Frames.Count; i++)
            {
                if (m_WorkingZone.Contains(m_Frames[i].Timestamp))
                {
                    continue;
                }

                if (m_Frames[i].Timestamp < m_WorkingZone.Start)
                {
                    removedAtLeft++;
                }

                DisposeFrame(m_Frames[i]);
                m_Frames[i] = null;

                if (i == m_CurrentIndex)
                {
                    m_CurrentIndex = -1;
                }
            }

            if (m_CurrentIndex >= removedAtLeft)
            {
                m_CurrentIndex -= removedAtLeft;
            }

            m_Frames.RemoveAll(frame => object.ReferenceEquals(null, frame));

            m_CurrentIndex = Math.Max(0, m_CurrentIndex);
            m_Current      = m_Frames[m_CurrentIndex];

            UpdateWorkingZone();
        }
Beispiel #4
0
 private bool Contains(long _timestamp)
 {
     return(m_WorkingZone.Contains(_timestamp));
 }