Ejemplo n.º 1
0
        public override void Read(BoxReader reader)
        {
            long testpos = reader.BaseStream.Position;

            using (new SizeChecker(this, reader)) {
                base.Read(reader);
                MovieHeaderBox.Read(reader);

                // Don't assume any order in the boxes within this after the header.
                // (The order depends on the brand.)
                int        tbcount = 0;
                TrackBox[] tmpTBs  = new TrackBox[10];
                while (reader.BaseStream.Position < (long)(this.Size + this.Offset))
                {
                    long pos = reader.BaseStream.Position;

                    Box tmpBox = new Box(BoxTypes.Any);
                    tmpBox.Read(reader);

                    reader.BaseStream.Position = pos;

                    if (tmpBox.Type == BoxTypes.Track)
                    {
                        TrackBox tb = new TrackBox(this, MovieHeaderBox.TimeScale);
                        tb.Read(reader);
                        tmpTBs[tbcount] = tb;
                        tbcount++;
                    }

                    else if (tmpBox.Type == BoxTypes.MovieExtends)
                    {
                        MovieExtendsBox = new MovieExtendsBox(this);
                        MovieExtendsBox.Read(reader);
                    }

                    else if (tmpBox.Type == BoxTypes.ObjectDescriptor) // iods
                    {
                        _objectDescriptor = new ObjectDescriptorBox();
                        _objectDescriptor.Read(reader);
                    }

                    else if (tmpBox.Type == BoxTypes.UserData) // udta
                    {
                        _userData = new UserDataBox();
                        _userData.Read(reader);
                    }

                    // some cases below for things we currently ignore, thus we skip over them...
                    else
                    {
                        byte[] buffer = new byte[tmpBox.Size];
                        reader.Read(buffer, 0, (int)tmpBox.Size);
                        //reader.BaseStream.Position = (long)(tmpBox.Size + tmpBox.Offset); // ignore for now
                        Debug.WriteLine(string.Format("Unknown box type {0} in MovieMetadataBox (this), skipped", tmpBox.Type.ToString()));
                    }
                }

                TrackBoxes = new TrackBox[tbcount];
                for (int i = 0; i < tbcount; i++)
                {
                    TrackBoxes[i] = tmpTBs[i];
                }
            }
        }
Ejemplo n.º 2
0
        public override void Read(BoxReader reader)
        {
            long testpos = reader.BaseStream.Position;
              using (new SizeChecker(this, reader)) {
            base.Read(reader);
            MovieHeaderBox.Read(reader);

            // Don't assume any order in the boxes within this after the header.
            // (The order depends on the brand.)
            int tbcount = 0;
            TrackBox[] tmpTBs = new TrackBox[10];
            while (reader.BaseStream.Position < (long)(this.Size + this.Offset)) {
              long pos = reader.BaseStream.Position;

              Box tmpBox = new Box(BoxTypes.Any);
              tmpBox.Read(reader);

              reader.BaseStream.Position = pos;

              if (tmpBox.Type == BoxTypes.Track)
              {
              TrackBox tb = new TrackBox(this, MovieHeaderBox.TimeScale);
              tb.Read(reader);
              tmpTBs[tbcount] = tb;
              tbcount++;
              }

              else if (tmpBox.Type == BoxTypes.MovieExtends)
              {
              MovieExtendsBox = new MovieExtendsBox(this);
              MovieExtendsBox.Read(reader);
              }

              else if (tmpBox.Type == BoxTypes.ObjectDescriptor) // iods
              {
            _objectDescriptor = new ObjectDescriptorBox();
            _objectDescriptor.Read(reader);
              }

              else if (tmpBox.Type == BoxTypes.UserData) // udta
              {
            _userData = new UserDataBox();
            _userData.Read(reader);
              }

              // some cases below for things we currently ignore, thus we skip over them...
              else
              {
            byte[] buffer = new byte[tmpBox.Size];
            reader.Read(buffer, 0, (int)tmpBox.Size);
            //reader.BaseStream.Position = (long)(tmpBox.Size + tmpBox.Offset); // ignore for now
            Debug.WriteLine(string.Format("Unknown box type {0} in MovieMetadataBox (this), skipped", tmpBox.Type.ToString()));
              }
            }

            TrackBoxes = new TrackBox[tbcount];
            for (int i = 0; i < tbcount; i++)
            {
            TrackBoxes[i] = tmpTBs[i];
            }

              }
        }