示例#1
0
        public static FramingLayer Parse(ReadOnlySpan <byte> bytes, RootLayerVector rootLayerVector)
        {
            var vector = (FramingLayerVector)BinaryPrimitives.ReadUInt32BigEndian(bytes.Slice(sizeof(UInt16)));

            switch (rootLayerVector)
            {
            case RootLayerVector.VECTOR_ROOT_E131_DATA:
                switch (vector)
                {
                case FramingLayerVector.VECTOR_E131_DATA_PACKET:
                    return(DataPacketFramingLayer.Parse(bytes));
                }
                break;

            case RootLayerVector.VECTOR_ROOT_E131_EXTENDED:
                switch (vector)
                {
                case FramingLayerVector.VECTOR_E131_EXTENDED_SYNCHRONIZATION:
                    return(SynchronizationPacketFramingLayer.Parse(bytes));

                case FramingLayerVector.VECTOR_E131_EXTENDED_DISCOVERY:
                    return(UniverseDiscoveryPacketFramingLayer.Parse(bytes));
                }
                break;
            }

            return(null);
        }
示例#2
0
        public static List <byte> GetRootLayer(byte[] cid, RootLayerVector vector)
        {
            var expectedVector = vector;
            var expectedFlags  = RootLayer.FLAGS;
            var expectedLength = RootLayer.Length - 16;

            var bytes = new List <byte>
            {
                0x00, 0x10,                 // preamble size
                0x00, 0x00,                 // postamble size
            };

            bytes.AddRange(RootLayer.ACNIdentifier);
            bytes.AddRange(new byte[]
            {
                (byte)(expectedFlags << 4), (byte)expectedLength,       // flags and length
                0x00, 0x00, 0x00, (byte)expectedVector,                 // vector
            });

            bytes.AddRange(cid);

            return(bytes);
        }