public void ReadDataFromBuffer(BufferChunk buffer) { Time = buffer.NextUInt64(); TimeStamp = buffer.NextUInt32(); PacketCount = buffer.NextUInt32(); BytesSent = buffer.NextUInt32(); }
/// <summary> /// Given a BufferChunk containing AM_SAMPLE2_PROPERTIES, return a filled-in struct. /// </summary> /// <param name="bc"></param> /// <returns></returns> private static AM_SAMPLE2_PROPERTIES ReconstituteSampleProperties(BufferChunk bc) { AM_SAMPLE2_PROPERTIES asp; asp.cbData = (uint)NextInt32(bc); asp.dwTypeSpecificFlags = (uint)NextInt32(bc); asp.dwSampleFlags = (uint)NextInt32(bc); asp.lActual = NextInt32(bc); asp.tStart = bc.NextUInt64(); asp.tStop = bc.NextUInt64(); asp.dwStreamId = (uint)NextInt32(bc); asp.pMediaType = (IntPtr)NextInt32(bc); asp.pbBuffer = (IntPtr)NextInt32(bc); asp.cbBuffer = NextInt32(bc); return(asp); }
/// <summary> /// Fill in the video-specific parts of the MediaType from the data in the BufferChunk. /// Also return the compression data which is the remaining bytes at the end of the byte[]. /// </summary> /// <param name="mt"></param> /// <param name="bc"></param> /// <param name="compressionData"></param> public static void ReconstituteVideoFormat(MediaTypeVideoInfo mt, BufferChunk bc, out byte[] compressionData) { VIDEOINFOHEADER vi; RECT s; s.left = NextInt32(bc); s.top = NextInt32(bc); s.right = NextInt32(bc); s.bottom = NextInt32(bc); vi.Source = s; RECT t; t.left = NextInt32(bc); t.top = NextInt32(bc); t.right = NextInt32(bc); t.bottom = NextInt32(bc); vi.Target = t; vi.BitRate = (uint)NextInt32(bc); vi.BitErrorRate = (uint)NextInt32(bc); vi.AvgTimePerFrame = bc.NextUInt64(); BITMAPINFOHEADER bih; bih.Size = (uint)NextInt32(bc); bih.Width = NextInt32(bc); bih.Height = NextInt32(bc); bih.Planes = (ushort)NextInt16(bc); bih.BitCount = (ushort)NextInt16(bc); bih.Compression = (uint)NextInt32(bc); bih.SizeImage = (uint)NextInt32(bc); bih.XPelsPerMeter = NextInt32(bc); bih.YPelsPerMeter = NextInt32(bc); bih.ClrUsed = (uint)NextInt32(bc); bih.ClrImportant = (uint)NextInt32(bc); vi.BitmapInfo = bih; mt.VideoInfo = vi; compressionData = new byte[bc.Length]; for (int i = 0; i < compressionData.Length; i++) { compressionData[i] = bc.NextByte(); } }