Exemplo n.º 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);
        }
Exemplo n.º 2
0
        public static DataPacketFramingLayer Parse(ReadOnlySpan <byte> bytes)
        {
            DataPacketFramingLayer framingLayer = new DataPacketFramingLayer();

            var flagsAndLength = BinaryPrimitives.ReadUInt16BigEndian(bytes);

            bytes = bytes.Slice(sizeof(UInt16));

            framingLayer.Vector = (FramingLayerVector)BinaryPrimitives.ReadUInt32BigEndian(bytes);
            bytes = bytes.Slice(sizeof(UInt32));

            var sourceNameBytes = bytes.Slice(0, 64);

            bytes = bytes.Slice(64);
            framingLayer.SourceName = Encoding.UTF8.GetString(sourceNameBytes.ToArray());

            framingLayer.Priority = bytes[0];
            bytes = bytes.Slice(sizeof(byte));

            framingLayer.SynchronizationAddress = BinaryPrimitives.ReadUInt16BigEndian(bytes);
            bytes = bytes.Slice(sizeof(UInt16));

            framingLayer.SequenceNumber = bytes[0];
            bytes = bytes.Slice(sizeof(byte));

            framingLayer.Options = bytes[0];
            bytes = bytes.Slice(sizeof(byte));

            framingLayer.Universe = BinaryPrimitives.ReadUInt16BigEndian(bytes);
            bytes = bytes.Slice(sizeof(UInt16));

            return(framingLayer);
        }