Example #1
0
 public MovieMetadataBox(List<IsochronousTrackInfo> trackInfos, float rate, float volume, uint[] matrix)
     : base(BoxTypes.Movie)
 {
     // initialize movie duration to zero, then increment it for every slice that is written
       ulong scaledDuration = (ulong)TimeArithmetic.ConvertToTimeScale(trackInfos[0].MovieTimeScale, trackInfos[0].MovieDurationIn100NanoSecs);
       MovieHeaderBox = new MovieHeaderBox(trackInfos[0].MovieTimeScale, scaledDuration, rate, volume, matrix);
       this.Size += MovieHeaderBox.Size;
       TrackBoxes = new TrackBox[trackInfos.Count];  // may have more than 2 tracks
       // MovieExtendsBox should only exist if this is a fragment
       if (trackInfos[0].IsFragment)
       {
     MovieExtendsBox = new MovieExtendsBox(this, trackInfos);
     this.Size += MovieExtendsBox.Size;
       }
 }
Example #2
0
        public MovieMetadataBox(List <IsochronousTrackInfo> trackInfos, float rate, float volume, uint[] matrix)
            : base(BoxTypes.Movie)
        {
            // initialize movie duration to zero, then increment it for every slice that is written
            ulong scaledDuration = (ulong)TimeArithmetic.ConvertToTimeScale(trackInfos[0].MovieTimeScale, trackInfos[0].MovieDurationIn100NanoSecs);

            MovieHeaderBox = new MovieHeaderBox(trackInfos[0].MovieTimeScale, scaledDuration, rate, volume, matrix);
            this.Size     += MovieHeaderBox.Size;
            TrackBoxes     = new TrackBox[trackInfos.Count]; // may have more than 2 tracks
            // MovieExtendsBox should only exist if this is a fragment
            if (trackInfos[0].IsFragment)
            {
                MovieExtendsBox = new MovieExtendsBox(this, trackInfos);
                this.Size      += MovieExtendsBox.Size;
            }
        }
Example #3
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];
                }
            }
        }
Example #4
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];
            }

              }
        }