/// <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) { EBMLreader child = new EBMLreader(_file, element.DataOffset + i); MatroskaID matroska_id = child.ID; switch (matroska_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: unknown_elems.Add(child); break; } i += child.Size; } }
/// <summary> /// Construct a <see cref="AudioTrack" /> reading information 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 AudioTrack(File _file, EBMLreader element) : base(_file, element) { MatroskaID matroska_id; // Here we handle the unknown elements we know, and store the rest foreach (EBMLreader elem in base.UnknownElements) { matroska_id = (MatroskaID)elem.ID; switch (matroska_id) { case MatroskaID.TrackAudio: { ulong i = 0; while (i < elem.DataSize) { EBMLreader child = new EBMLreader(_file, elem.DataOffset + i); matroska_id = (MatroskaID)child.ID; switch (matroska_id) { case MatroskaID.AudioChannels: channels = child.ReadULong(); break; case MatroskaID.AudioBitDepth: depth = child.ReadULong(); break; case MatroskaID.AudioSamplingFreq: rate = child.ReadDouble(); break; default: unknown_elems.Add(child); break; } i += child.Size; } break; } default: unknown_elems.Add(elem); break; } } }
/// <summary> /// Constructs a root <see cref="EBMLreader" /> instance, by reading from /// the provided file position. /// </summary> /// <param name="_file"><see cref="File" /> File instance to read from.</param> /// <param name="position">Position in the file to start reading from.</param> public EBMLreader(Matroska.File _file, ulong position) { // Keep a reference to the file file = _file; parent = null; // Initialize attributes offset = position; data_offset = position; ebml_id = 0; ebml_size = 0; // Actually read the EBML on the file Read(true); }
/// <summary> /// Create a new abstract <see cref="EBMLreader" /> with arbitrary attributes, /// without reading its information on the file. /// </summary> /// <param name="parent">The <see cref="EBMLreader" /> that contains the instance to be described.</param> /// <param name="position">Position in the file.</param> /// <param name="ebmlid">EBML ID of the element</param> /// <param name="size">Total size of the EBML, in bytes</param> public EBMLreader(EBMLreader parent, ulong position, MatroskaID ebmlid, ulong size = 0) { // Keep a reference to the file if (parent != null) { file = parent.file; } this.parent = parent; // Initialize attributes offset = position; data_offset = offset; ebml_id = (uint)ebmlid; ebml_size = size; }
/// <summary> /// Constructs a <see cref="SubtitleTrack" /> 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 SubtitleTrack(File _file, EBMLreader element) : base(_file, element) { // Here we handle the unknown elements we know, and store the rest foreach (EBMLreader elem in base.UnknownElements) { MatroskaID matroska_id = (MatroskaID)elem.ID; switch (matroska_id) { default: unknown_elems.Add(elem); break; } } }
/// <summary> /// Constructs a child <see cref="EBMLreader" /> reading the data from the /// EBML parent at the provided file position. /// </summary> /// <param name="parent">The <see cref="EBMLreader" /> that contains the instance to be created.</param> /// <param name="position">Position in the file to start reading from.</param> public EBMLreader(EBMLreader parent, ulong position) { if (parent == null) { throw new ArgumentNullException("file"); } // Keep a reference to the file file = parent.file; this.parent = parent; // Initialize attributes offset = position; data_offset = position; ebml_id = 0; ebml_size = 0; // Actually read the EBML on the file Read(true); }
/// <summary> /// Constructs a child <see cref="EBMLreader" /> reading the data from the /// EBML parent at the provided file position. /// </summary> /// <param name="parent">The <see cref="EBMLreader" /> that contains the instance to be created.</param> /// <param name="position">Position in the file to start reading from.</param> public EBMLreader(EBMLreader parent, ulong position) { if (parent == null) { throw new ArgumentNullException(nameof(parent)); } // Keep a reference to the file file = parent.file; Parent = parent; // Initialize attributes offset = position; DataOffset = position; ebml_id = 0; DataSize = 0; // Actually read the EBML on the file Read(true); }
/// <summary> /// Constructs a <see cref="VideoTrack" /> 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 VideoTrack(File _file, EBMLreader element) : base(_file, element) { MatroskaID matroska_id; // Here we handle the unknown elements we know, and store the rest foreach (EBMLreader elem in base.UnknownElements) { matroska_id = (MatroskaID)elem.ID; switch (matroska_id) { case MatroskaID.TrackVideo: { ulong i = 0; while (i < elem.DataSize) { EBMLreader child = new EBMLreader(_file, elem.DataOffset + i); matroska_id = (MatroskaID)child.ID; switch (matroska_id) { case MatroskaID.VideoDisplayWidth: disp_width = child.ReadULong(); break; case MatroskaID.VideoDisplayHeight: disp_height = child.ReadULong(); break; case MatroskaID.VideoPixelWidth: width = child.ReadULong(); break; case MatroskaID.VideoPixelHeight: height = child.ReadULong(); break; case MatroskaID.VideoFrameRate: framerate = child.ReadDouble(); break; case MatroskaID.VideoFlagInterlaced: interlaced = child.ReadBool(); break; case MatroskaID.VideoAspectRatioType: ratio_type = (VideoAspectRatioType)child.ReadULong(); break; case MatroskaID.VideoColourSpace: fourcc = child.ReadBytes(); break; default: unknown_elems.Add(child); break; } i += child.Size; } break; } case MatroskaID.TrackDefaultDuration: ulong tmp = elem.ReadULong(); framerate = 1000000000.0 / (double)tmp; break; default: unknown_elems.Add(elem); break; } } }