예제 #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)
            {
                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;
            }
        }
예제 #2
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 (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;
                }
            }
        }