Esempio n. 1
0
 public MatroskaFileTrack GetTrack(int trackNumber)
 {
     for (int t = 0; t < trackList.Count; t++)
     {
         MatroskaFileTrack track = trackList[t];
         if (track.TrackNumber == trackNumber)
         {
             return(track);
         }
     }
     return(null);
 }
Esempio n. 2
0
 private void parseTracks(Element level1, Element level2)
 {
     level2 = ((MasterElement)level1).ReadNextChild(reader);
     while (level2 != null)
     {
         if (level2.IsType(MatroskaDocTypes.TrackEntry.Type))
         {
             trackList.Add(MatroskaFileTrack.FromElement(level2, stream, reader));
         }
         level2.SkipData(stream);
         level2 = ((MasterElement)level1).ReadNextChild(reader);
     }
 }
 public void AddTrack(MatroskaFileTrack track)
 {
     tracks.Add(track);
 }
Esempio n. 4
0
        public static MatroskaFileTrack FromElement(Element level2, FileStream source, EbmlReader reader)
        {
            Element level3 = ((MasterElement)level2).ReadNextChild(reader);
            Element level4 = null;

            MatroskaFileTrack track = new MatroskaFileTrack();

            Utility.LogDebug("Reading track from doc!");
            while (level3 != null)
            {
                if (level3.IsType(MatroskaDocTypes.TrackNumber.Type))
                {
                    level3.ReadData(source);
                    track.TrackNumber = ((int)((UnsignedIntegerElement)level3).Value);
                }
                else if (level3.IsType(MatroskaDocTypes.TrackUID.Type))
                {
                    level3.ReadData(source);
                    track.TrackUID = ((UnsignedIntegerElement)level3).Value;
                }
                else if (level3.IsType(MatroskaDocTypes.TrackType.Type))
                {
                    level3.ReadData(source);
                    track.TrackType = (TrackType)((UnsignedIntegerElement)level3).Value;
                }
                else if (level3.IsType(MatroskaDocTypes.DefaultDuration.Type))
                {
                    level3.ReadData(source);
                    track.DefaultDuration = ((UnsignedIntegerElement)level3).Value;
                }
                else if (level3.IsType(MatroskaDocTypes.Name.Type))
                {
                    level3.ReadData(source);
                    track.Name = ((StringElement)level3).Value;
                }
                else if (level3.IsType(MatroskaDocTypes.Language.Type))
                {
                    level3.ReadData(source);
                    track.Language = ((StringElement)level3).Value;
                }
                else if (level3.IsType(MatroskaDocTypes.CodecID.Type))
                {
                    level3.ReadData(source);
                    track.CodecId = ((StringElement)level3).Value;
                }
                else if (level3.IsType(MatroskaDocTypes.CodecPrivate.Type))
                {
                    level3.ReadData(source);
                    track.CodecPrivate = ((BinaryElement)level3).Data;
                }
                else if (level3.IsType(MatroskaDocTypes.Video.Type))
                {
                    level4      = ((MasterElement)level3).ReadNextChild(reader);
                    track.video = new MatroskaVideoTrack();
                    while (level4 != null)
                    {
                        if (level4.IsType(MatroskaDocTypes.PixelWidth.Type))
                        {
                            level4.ReadData(source);
                            track.video.PixelWidth = (short)((UnsignedIntegerElement)level4).Value;
                        }
                        else if (level4.IsType(MatroskaDocTypes.PixelHeight.Type))
                        {
                            level4.ReadData(source);
                            track.video.PixelHeight = (short)((UnsignedIntegerElement)level4).Value;
                        }
                        else if (level4.IsType(MatroskaDocTypes.DisplayWidth.Type))
                        {
                            level4.ReadData(source);
                            track.video.DisplayWidth = (short)((UnsignedIntegerElement)level4).Value;
                        }
                        else if (level4.IsType(MatroskaDocTypes.DisplayHeight.Type))
                        {
                            level4.ReadData(source);
                            track.video.DisplayHeight = (short)((UnsignedIntegerElement)level4).Value;
                        }

                        level4.SkipData(source);
                        level4 = ((MasterElement)level3).ReadNextChild(reader);
                    }
                }
                else if (level3.IsType(MatroskaDocTypes.Audio.Type))
                {
                    level4      = ((MasterElement)level3).ReadNextChild(reader);
                    track.audio = new MatroskaAudioTrack();
                    while (level4 != null)
                    {
                        if (level4.IsType(MatroskaDocTypes.SamplingFrequency.Type))
                        {
                            level4.ReadData(source);
                            track.audio.SamplingFrequency = (float)((FloatElement)level4).Value;
                        }
                        else if (level4.IsType(MatroskaDocTypes.OutputSamplingFrequency.Type))
                        {
                            level4.ReadData(source);
                            track.audio.OutputSamplingFrequency = (float)((FloatElement)level4).Value;
                        }
                        else if (level4.IsType(MatroskaDocTypes.Channels.Type))
                        {
                            level4.ReadData(source);
                            track.audio.Channels = (short)((UnsignedIntegerElement)level4).Value;
                        }
                        else if (level4.IsType(MatroskaDocTypes.BitDepth.Type))
                        {
                            level4.ReadData(source);
                            track.audio.BitDepth = (byte)((UnsignedIntegerElement)level4).Value;
                        }

                        level4.SkipData(source);
                        level4 = ((MasterElement)level3).ReadNextChild(reader);
                    }
                }

                level3.SkipData(source);
                level3 = ((MasterElement)level2).ReadNextChild(reader);
            }
            Utility.LogDebug("Read track from doc!");
            return(track);
        }