Beispiel #1
0
        public static QuantizedTimeZonesDescriptor Parse(ref ReadOnlySpan <byte> buffer)
        {
            QuantizedTimeZonesDescriptor descriptor = default;

            ParseHeader(ref buffer, Tag.Span);

            descriptor.HeadSize        = ParseInt(ref buffer);
            descriptor.PacketSize      = ParseInt(ref buffer);
            descriptor.Unknown1        = ParseInt(ref buffer);
            descriptor.Unknown2        = ParseInt(ref buffer);
            descriptor.QuantizedPoints = ParseQuantizedList(ref buffer);

            return(descriptor);
        }
Beispiel #2
0
        public static void ParseFile(ref ReadOnlySpan <byte> file,
                                     Action <MainFileDescriptor> mainFileDescriptorAction = null,
                                     FilePathDescriptorAction filePathDescriptorAction    = null,
                                     CueObjectDescriptorAction cueObjectDescriptorAction  = null,
                                     QuantizedTimeZonesDescriptorAction quantizedTimeZonesDescriptorAction = null,
                                     VbrSeekTableDescriptorAction vbrSeekTableDescriptorAction             = null,
                                     WaveDisplayDataDescriptorAction <ColoredWaveDataPoint> coloredWaveDisplayDataDescriptorAction       = null,
                                     WaveDisplayDataDescriptorAction <NonColoredWaveDataPoint> nonColoredWaveDisplayDataDescriptorAction = null,
                                     UnknownHeaderDescriptorAction unknownHeaderDescriptorAction = null)
        {
            while (!file.IsEmpty)
            {
                var type = PeekType(file);

                if (type.SequenceEqual(MainFileDescriptor.Tag.Span))
                {
                    MainFileDescriptor mainFileDescriptor = MainFileDescriptor.Parse(ref file);
                    mainFileDescriptorAction?.Invoke(mainFileDescriptor);
                }
                else if (type.SequenceEqual(FilePathDescriptor.Tag.Span))
                {
                    FilePathDescriptor filePathDescriptor = FilePathDescriptor.Parse(ref file);
                    filePathDescriptorAction?.Invoke(filePathDescriptor);
                }
                else if (type.SequenceEqual(CueObjectDescriptor.Tag.Span))
                {
                    CueObjectDescriptor cueObjectDescriptor = CueObjectDescriptor.Parse(ref file);
                    cueObjectDescriptorAction?.Invoke(cueObjectDescriptor);
                }
                else if (type.SequenceEqual(QuantizedTimeZonesDescriptor.Tag.Span))
                {
                    QuantizedTimeZonesDescriptor quantizedTimeZonesDescriptor = QuantizedTimeZonesDescriptor.Parse(ref file);
                    quantizedTimeZonesDescriptorAction?.Invoke(quantizedTimeZonesDescriptor);
                }
                else if (type.SequenceEqual(VbrSeekTableDescriptor.Tag.Span))
                {
                    VbrSeekTableDescriptor vbrSeekTableDescriptor = VbrSeekTableDescriptor.Parse(ref file);
                    vbrSeekTableDescriptorAction?.Invoke(vbrSeekTableDescriptor);
                }
                else if (type.StartsWith(WaveDisplayDataDescriptor <bool> .Tag.Span))
                {
                    if (WaveDisplayDataDescriptor <bool> .IsColored(type))
                    {
                        WaveDisplayDataDescriptor <ColoredWaveDataPoint> coloredWaveDisplayDataDescriptor = WaveDisplayDataDescriptor <ColoredWaveDataPoint> .Parse(ref file);

                        coloredWaveDisplayDataDescriptorAction?.Invoke(coloredWaveDisplayDataDescriptor);
                    }
                    else
                    {
                        WaveDisplayDataDescriptor <NonColoredWaveDataPoint> nonColoredWaveDisplayDataDescriptor = WaveDisplayDataDescriptor <NonColoredWaveDataPoint> .Parse(ref file);

                        nonColoredWaveDisplayDataDescriptorAction?.Invoke(nonColoredWaveDisplayDataDescriptor);
                    }
                }
                else
                {
                    UnknownHeaderDescriptor unknownHeaderDescriptor = UnknownHeaderDescriptor.Parse(ref file);
                    // Console.WriteLine("Unknown header: " + unknownHeaderDescriptor.GetHeaderName());
                    unknownHeaderDescriptorAction?.Invoke(unknownHeaderDescriptor);
                }
            }
        }