Exemple #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);

                var 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:
                    UnknownElements.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 (var elem in base.UnknownElements)
            {
                matroska_id = elem.ID;

                switch (matroska_id)
                {
                case MatroskaID.TrackAudio:
                {
                    ulong i = 0;

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

                        matroska_id = 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:
                            UnknownElements.Add(child);
                            break;
                        }

                        i += child.Size;
                    }

                    break;
                }

                default:
                    UnknownElements.Add(elem);
                    break;
                }
            }
        }
        /// <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 = elem.ID;

                switch (matroska_id)
                {
                default:
                    UnknownElements.Add(elem);
                    break;
                }
            }
        }
Exemple #4
0
        /// <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 (var elem in base.UnknownElements)
            {
                matroska_id = elem.ID;

                switch (matroska_id)
                {
                case MatroskaID.TrackVideo:
                {
                    ulong i = 0;

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

                        matroska_id = 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:
                            UnknownElements.Add(child);
                            break;
                        }

                        i += child.Size;
                    }

                    break;
                }

                case MatroskaID.TrackDefaultDuration:
                    var tmp = elem.ReadULong();
                    framerate = 1000000000.0 / tmp;
                    break;

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