Example #1
0
        /// <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="EBMLElement" />.</param>
        public AudioTrack(File _file, EBMLElement element)
            : base(_file, element)
        {
            MatroskaID matroska_id;

            // Here we handle the unknown elements we know, and store the rest
            foreach (EBMLElement elem in base.UnknownElements)
            {
                matroska_id = (MatroskaID)elem.ID;

                if (matroska_id == MatroskaID.MatroskaTrackAudio)
                {
                    ulong i = 0;

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

                        matroska_id = (MatroskaID)child.ID;

                        switch (matroska_id)
                        {
                        case MatroskaID.MatroskaAudioChannels:
                            channels = child.ReadUInt();
                            break;

                        case MatroskaID.MatroskaAudioBitDepth:
                            depth = child.ReadUInt();
                            break;

                        case MatroskaID.MatroskaAudioSamplingFreq:
                            rate = child.ReadDouble();
                            break;

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

                        i += child.Size;
                    }
                }
                else
                {
                    unknown_elems.Add(elem);
                }
            }
        }
Example #2
0
        /// <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="EBMLElement" />.</param>
        public AudioTrack (File _file, EBMLElement element)
            : base (_file, element)
        {
            MatroskaID matroska_id;

            // Here we handle the unknown elements we know, and store the rest
            foreach (EBMLElement elem in base.UnknownElements) {

                matroska_id = (MatroskaID) elem.ID;

                if (matroska_id == MatroskaID.MatroskaTrackAudio) {
                    ulong i = 0;

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

                        matroska_id = (MatroskaID) child.ID;

                        switch (matroska_id) {
                            case MatroskaID.MatroskaAudioChannels:
                                channels = child.ReadUInt ();
                                break;
                            case MatroskaID.MatroskaAudioBitDepth:
                                depth = child.ReadUInt ();
                                break;
                            case MatroskaID.MatroskaAudioSamplingFreq:
                                rate = child.ReadDouble ();
                                break;
                            default:
                                unknown_elems.Add (child);
                                break;
                        }

                        i += child.Size;
                    }
                }
                else {
                    unknown_elems.Add (elem);
                }
            }
        }
Example #3
0
        private void ReadSegmentInfo(EBMLElement element)
        {
            ulong i = 0;

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

                MatroskaID matroska_id = (MatroskaID)child.ID;

                switch (matroska_id)
                {
                case MatroskaID.MatroskaDuration:
                    duration_unscaled = (UInt64)child.ReadDouble();
                    if (time_scale > 0)
                    {
                        duration = TimeSpan.FromSeconds(duration_unscaled * time_scale / 1000000000);
                    }
                    break;

                case MatroskaID.MatroskaTimeCodeScale:
                    time_scale = child.ReadUInt();
                    if (duration_unscaled > 0)
                    {
                        duration = TimeSpan.FromSeconds(duration_unscaled * time_scale / 1000000000);
                    }
                    break;

                case MatroskaID.MatroskaTitle:
                    title = child.ReadString();
                    break;

                default:
                    break;
                }

                i += child.Size;
            }
        }
Example #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="EBMLElement" />.</param>
        public VideoTrack (File _file, EBMLElement element)
            : base (_file, element)
        {
            MatroskaID matroska_id;

            // Here we handle the unknown elements we know, and store the rest
            foreach (EBMLElement elem in base.UnknownElements) {
                matroska_id = (MatroskaID) elem.ID;

                if (matroska_id == MatroskaID.MatroskaTrackVideo) {
                    ulong i = 0;

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

                        matroska_id = (MatroskaID) child.ID;

                        switch (matroska_id) {
                            case MatroskaID.MatroskaVideoDisplayWidth:
                                disp_width = child.ReadUInt ();
                                break;
                            case MatroskaID.MatroskaVideoDisplayHeight:
                                disp_height = child.ReadUInt ();
                                break;
                            case MatroskaID.MatroskaVideoPixelWidth:
                                width = child.ReadUInt ();
                                break;
                            case MatroskaID.MatroskaVideoPixelHeight:
                                height = child.ReadUInt ();
                                break;
                            case MatroskaID.MatroskaVideoFrameRate:
                                framerate = child.ReadDouble ();
                                break;
                            case MatroskaID.MatroskaVideoFlagInterlaced:
                                interlaced = child.ReadBool ();
                                break;
                            case MatroskaID.MatroskaVideoAspectRatioType:
                                ratio_type = (VideoAspectRatioType) child.ReadUInt ();
                                break;
                            case MatroskaID.MatroskaVideoColourSpace:
                                fourcc = child.ReadBytes ();
                                break;
                            default:
                                unknown_elems.Add (child);
                                break;
                        }

                        i += child.Size;
                    }
                }
                else if (matroska_id == MatroskaID.MatroskaTrackDefaultDuration) {
                    uint tmp = elem.ReadUInt ();
                    framerate = 1000000000.0 / (double) tmp;
                }
                else {
                    unknown_elems.Add (elem);
                }
            }
        }
Example #5
0
        public VideoTrack(File _file, EBMLElement element) :
            base(_file, element)
        {
            MatroskaID matroska_id;

            foreach (EBMLElement elem in base.UnknownElements)
            {
                matroska_id = (MatroskaID)elem.ID;
                if (matroska_id == MatroskaID.MatroskaTrackVideo)
                {
                    ulong i = 0;
                    while (i < elem.DataSize)
                    {
                        EBMLElement child = new EBMLElement(_file, elem.DataOffset + i);
                        matroska_id = (MatroskaID)child.ID;
                        switch (matroska_id)
                        {
                        case MatroskaID.MatroskaVideoDisplayWidth:
                            disp_width = child.ReadUInt();
                            break;

                        case MatroskaID.MatroskaVideoDisplayHeight:
                            disp_height = child.ReadUInt();
                            break;

                        case MatroskaID.MatroskaVideoPixelWidth:
                            width = child.ReadUInt();
                            break;

                        case MatroskaID.MatroskaVideoPixelHeight:
                            height = child.ReadUInt();
                            break;

                        case MatroskaID.MatroskaVideoFrameRate:
                            framerate = child.ReadDouble();
                            break;

                        case MatroskaID.MatroskaVideoFlagInterlaced:
                            interlaced = child.ReadBool();
                            break;

                        case MatroskaID.MatroskaVideoAspectRatioType:
                            ratio_type = (VideoAspectRatioType)child.ReadUInt();
                            break;

                        case MatroskaID.MatroskaVideoColourSpace:
                            fourcc = child.ReadBytes();
                            break;

                        default:
                            unknown_elems.Add(child);
                            break;
                        }
                        i += child.Size;
                    }
                }
                else if (matroska_id == MatroskaID.MatroskaTrackDefaultDuration)
                {
                    uint tmp = elem.ReadUInt();
                    framerate = 1000000000.0 / (double)tmp;
                }
                else
                {
                    unknown_elems.Add(elem);
                }
            }
        }
Example #6
0
        private void ReadSegmentInfo (EBMLElement element)
        {
            ulong i = 0;

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

                MatroskaID matroska_id = (MatroskaID) child.ID;

                switch (matroska_id) {
                    case MatroskaID.MatroskaDuration:
                        duration_unscaled = (UInt64) child.ReadDouble ();
                        if (time_scale > 0) {
                            duration = TimeSpan.FromSeconds (duration_unscaled * time_scale / 1000000000);
                        }
                        break;
                    case MatroskaID.MatroskaTimeCodeScale:
                        time_scale = child.ReadUInt ();
                        if (duration_unscaled > 0) {
                            duration = TimeSpan.FromSeconds (duration_unscaled * time_scale / 1000000000);
                        }
                        break;
                    case MatroskaID.MatroskaTitle:
                        title = child.ReadString ();
                        break;
                    default:
                        break;
                }

                i += child.Size;
            }
        }