internal static FramingLayer Parse(BigEndianBinaryReader buffer) { UInt16 flagsAndFramingLength = (UInt16)buffer.ReadInt16(); UInt16 flags = (UInt16)(flagsAndFramingLength & SACNPacket.FIRST_FOUR_BITS_MASK); Debug.Assert(flags == SACNPacket.FLAGS); UInt16 length = (UInt16)(flagsAndFramingLength & SACNPacket.LAST_TWELVE_BITS_MASK); Int32 vector2 = buffer.ReadInt32(); Debug.Assert(vector2 == FRAMING_VECTOR); byte[] sourceNameBytes = buffer.ReadBytes(64); string sourceName = new string(Encoding.UTF8.GetChars(sourceNameBytes)).TrimEnd('\0'); byte priority = buffer.ReadByte(); Int16 reserved = buffer.ReadInt16(); Debug.Assert(reserved == RESERVED); byte sequenceID = buffer.ReadByte(); byte options = buffer.ReadByte(); UInt16 universeID = buffer.ReadUInt16(); FramingLayer framingLayer = new FramingLayer() { SourceName = sourceName, Priority = priority, SequenceID = sequenceID, Options = FramingOptions.Parse(options), UniverseID = universeID, DMPLayer = DMPLayer.Parse(buffer) }; return(framingLayer); }
internal static RootLayer Parse(BigEndianBinaryReader buffer) { Int16 preambleLength = buffer.ReadInt16(); Debug.Assert(preambleLength == PREAMBLE_LENGTH); Int16 postambleLength = buffer.ReadInt16(); Debug.Assert(postambleLength == POSTAMBLE_LENGTH); byte[] packetIdentifier = buffer.ReadBytes(12); Debug.Assert(packetIdentifier.SequenceEqual(PACKET_IDENTIFIER)); UInt16 flagsAndRootLength = (UInt16)buffer.ReadInt16(); UInt16 flags = (UInt16)(flagsAndRootLength & SACNPacket.FIRST_FOUR_BITS_MASK); Debug.Assert(flags == SACNPacket.FLAGS); UInt16 length = (UInt16)(flagsAndRootLength & SACNPacket.LAST_TWELVE_BITS_MASK); Int32 vector = buffer.ReadInt32(); Debug.Assert(vector == ROOT_VECTOR); Guid cid = new Guid(buffer.ReadBytes(16)); RootLayer rootLayer = new RootLayer() { UUID = cid, FramingLayer = FramingLayer.Parse(buffer) }; return(rootLayer); }
public byte[] ToArray() { using (var stream = new MemoryStream(Length)) using (var buffer = new BigEndianBinaryWriter(stream)) { buffer.Write(PREAMBLE_LENGTH); buffer.Write(POSTAMBLE_LENGTH); buffer.Write(PACKET_IDENTIFIER); UInt16 flagsAndRootLength = (UInt16)(SACNPacket.FLAGS | (UInt16)(Length - 16)); buffer.Write(flagsAndRootLength); buffer.Write(ROOT_VECTOR); buffer.Write(UUID.ToByteArray()); buffer.Write(FramingLayer.ToArray()); return(stream.ToArray()); } }
public RootLayer(Guid uuid, string sourceName, UInt16 universeID, byte sequenceID, byte[] data, byte priority) { UUID = uuid; FramingLayer = new FramingLayer(sourceName, universeID, sequenceID, data, priority); }