Example #1
0
        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);
        }