Пример #1
0
        /// <summary>
        ///     Constructs a <see cref="Track" /> parsing from provided
        ///     file data.
        ///     Parsing will be done reading from _file at position references by
        ///     parent element's data section.
        /// </summary>
        /// <param name="_file"><see cref="File" /> instance to read from.</param>
        /// <param name="element">Parent <see cref="EBMLreader" />.</param>
        public Track(File _file, EBMLreader element)
        {
            ulong i = 0;

            while (i < element.DataSize)
            {
                var child = new EBMLreader(_file, element.DataOffset + i);

                switch (child.ID)
                {
                case MatroskaID.TrackNumber:
                    track_number = child.ReadULong();
                    break;

                case MatroskaID.TrackUID:
                    _UID = child.ReadULong();
                    break;

                case MatroskaID.CodecID:
                    track_codec_id = child.ReadString();
                    break;

                case MatroskaID.CodecName:
                    track_codec_name = child.ReadString();
                    break;

                case MatroskaID.TrackName:
                    track_name = child.ReadString();
                    break;

                case MatroskaID.TrackLanguage:
                    track_language = child.ReadString();
                    break;

                case MatroskaID.TrackFlagEnabled:
                    track_enabled = child.ReadBool();
                    break;

                case MatroskaID.TrackFlagDefault:
                    track_default = child.ReadBool();
                    break;

                case MatroskaID.CodecPrivate:
                    codec_data = child.ReadBytes();
                    break;

                default:
                    UnknownElements.Add(child);
                    break;
                }

                i += child.Size;
            }
        }
Пример #2
0
        private void ReadHeader(EBMLreader element)
        {
            string doctype = null;
            ulong  i       = 0;

            while (i < element.DataSize)
            {
                var child = new EBMLreader(element, element.DataOffset + i);

                switch ((EBMLID)child.ID)
                {
                case EBMLID.EBMLDocType:
                    doctype = child.ReadString();
                    break;
                }

                i += child.Size;
            }

            // Check DocType
            if (string.IsNullOrEmpty(doctype) || doctype != "matroska" && doctype != "webm")
            {
                throw new UnsupportedFormatException("DocType is not matroska or webm");
            }
        }
Пример #3
0
        private void ReadAttachedFile(EBMLreader element, ReadStyle propertiesStyle)
        {
            ulong i = 0;

#pragma warning restore 219

            while (i < element.DataSize)
            {
                var child = new EBMLreader(element, element.DataOffset + i);

                switch (child.ID)
                {
                case MatroskaID.FileName:
#pragma warning disable 219 // Assigned, never read
                    _ = child.ReadString();
                    break;

                case MatroskaID.FileMimeType:
                    _ = child.ReadString();
                    break;

                case MatroskaID.FileDescription:
                    _ = child.ReadString();
                    break;

                case MatroskaID.FileData:
                    break;

                case MatroskaID.FileUID:
                    _ = child.ReadULong();
                    break;
                }

                i += child.Size;
            }
        }