public void Unpack(byte[] buffer, ref int offset, int count) { if (count < GetByteLength()) { throw new ArgumentOutOfRangeException(nameof(count)); } var bitOffset = 0; CsrcCount = BufferBits.GetByte(buffer, offset, ref bitOffset, 4); HasExtension = BufferBits.GetBool(buffer, offset, ref bitOffset); HasPadding = BufferBits.GetBool(buffer, offset, ref bitOffset); Version = BufferBits.GetByte(buffer, ref offset, ref bitOffset, 2); if (Version != DEFAULT_VERSION_VALUE) { throw new ArgumentException(nameof(Version)); } bitOffset = 0; PayloadType = BufferBits.GetByte(buffer, offset, ref bitOffset, 7); Marker = BufferBits.GetBool(buffer, ref offset, ref bitOffset); SequenceNumber = BufferBits.GetUInt16(buffer, ref offset); TimeStamp = BufferBits.GetUInt32(buffer, ref offset); Ssrc = BufferBits.GetUInt32(buffer, ref offset); if (count < GetByteLength()) { throw new ArgumentOutOfRangeException(nameof(count)); } for (int i = 0; i < CsrcCount; i++) { _csrcList.Add(BufferBits.GetUInt32(buffer, ref offset)); } if (HasExtension) { Extension.Unpack(buffer, ref offset, buffer.Length); } var payloadCount = buffer.Length - offset; if (HasPadding) { var remain = buffer.Length - 1; PaddingCount = BufferBits.GetByte(buffer, ref remain); if (PaddingCount > 0) { payloadCount -= PaddingCount; } } Payload = BufferBits.GetBytes(buffer, ref offset, payloadCount); if (HasPadding) { offset += PaddingCount; } }
public void Unpack(byte[] buffer, ref int offset, int count) { if (count < GetByteLength()) { throw new ArgumentOutOfRangeException(nameof(count)); } Profile = BufferBits.GetUInt16(buffer, ref offset); Length = BufferBits.GetUInt16(buffer, ref offset); for (int i = 0; i < Length; i++) { _extensionList.Add(BufferBits.GetUInt32(buffer, ref offset)); } offset += Extension.Count * 8; }