bool PushBody(ArraySegment <Byte> bytes) { bool hasNewFrame = false; var i = 0; while (i < bytes.Count) { i = m_next.Push(bytes, i); if (m_next.IsFill) { YUVFrameReader tmp; lock (m_currentLock) { tmp = m_current; m_current = m_next; } m_next = tmp; m_next.Clear(m_frameNumber++); hasNewFrame = true; } } return(hasNewFrame); }
public void Push(ArraySegment <Byte> bytes) { if (Header == null) { m_buffer.AddRange(bytes.ToE()); var index = m_buffer.IndexOf(0x0A); if (index == -1) { return; } var tmp = m_buffer.Take(index).ToArray(); Header = YUVHeader.Parse(Encoding.ASCII.GetString(tmp)); m_current = new YUVFrameReader(Header); m_next = new YUVFrameReader(Header); PushBody(new ArraySegment <Byte>(m_buffer.Skip(index + 1).ToArray())); m_buffer.Clear(); } else { PushBody(bytes); } }