Example #1
0
 public override void Read(BoxReader reader)
 {
     long pos = reader.BaseStream.Position;
       base.Read(reader);
       data = new byte[base.Size - 8];
       reader.Read(data, 0, data.Length); // FIXME: useless all-zero data - should we even read?
 }
Example #2
0
        public override void Read(BoxReader reader)
        {
            long pos = reader.BaseStream.Position;

            base.Read(reader);
            data = new byte[base.Size - 8];
            reader.Read(data, 0, data.Length); // FIXME: useless all-zero data - should we even read?
        }
Example #3
0
 public override void Read(BoxReader reader)
 {
     using (new SizeChecker(this, reader))
       {
     base.Read(reader);
     _data = new byte[base.Size - 8];
     reader.Read(_data, 0, _data.Length);
       }
 }
Example #4
0
 public override void Read(BoxReader reader)
 {
     using (new SizeChecker(this, reader))
     {
         base.Read(reader);
         _data = new byte[base.Size - 8];
         reader.Read(_data, 0, _data.Length);
     }
 }
 public override void Read(BoxReader reader)
 {
     using (new SizeChecker(this, reader))
       {
       base.Read(reader);
       codecPrivateData = new byte[Size - 8L];
       reader.Read(codecPrivateData, 0, codecPrivateData.Length);
       }
 }
Example #6
0
 public override void Read(BoxReader reader)
 {
     using (new SizeChecker(this, reader))
     {
         base.Read(reader);
         _contents = new byte[base.Size - 8UL];
         reader.Read(_contents, 0, _contents.Length);
     }
 }
 public override void Read(BoxReader reader)
 {
     using (new SizeChecker(this, reader))
       {
     base.Read(reader);
     _contents = new byte[base.Size - 8UL];
     reader.Read(_contents, 0, _contents.Length);
       }
 }
 public override void Read(BoxReader reader)
 {
     using (new SizeChecker(this, reader)) {
         base.Read(reader);
         reader.ReadInt32();
         reader.Read(handler_type, 0, 4);
         for (int i = 0; i < 3; i++)
         {
             reader.ReadUInt32();
         }
         Name = reader.ReadNullTerminatedString();
         // special case to take care of Apple's bug
         // (Apple and GoPro prepends the string with char count, but then adds one byte too many to the box size.)
         if (reader.BaseStream.Position != (long)(this.Size + this.Offset))
         {
             reader.BaseStream.Position = (long)(this.Size + this.Offset);
             Name = Name.Substring(1);
         }
     }
 }
Example #9
0
        public override void Read(BoxReader reader)
        {
            using (new SizeChecker(this, reader)) {
                base.Read(reader);
                if (Version == 1)
                {
                    creationTime     = reader.ReadUInt64();
                    modificationTime = reader.ReadUInt64();
                    TimeScale        = reader.ReadUInt32();
                    Duration         = reader.ReadUInt64();
                }
                else
                {
                    creationTime     = (UInt64)reader.ReadUInt32();
                    modificationTime = (UInt64)reader.ReadUInt32();
                    TimeScale        = reader.ReadUInt32();
                    Duration         = (UInt64)reader.ReadUInt32();
                }

                // Set rate 16.16.
                rate[0] = reader.ReadUInt16();
                rate[1] = reader.ReadUInt16();

                // Set _volume.
                reader.Read(volume, 0, 2);

                reader.ReadInt16(); // bit[16] - reserved = 0
                for (int x = 0; x < 2; x++)
                {
                    reader.ReadUInt32();                 // bit(32)[2] - pre_defined = 0
                }
                this.Matrix.Read(reader);
                for (int x = 0; x < 6; x++)
                {
                    reader.ReadUInt32();                 // bit(32)[6] - pre_defined = 0
                }
                NextTrackID = reader.ReadUInt32();
            }
        }
 public override void Read(BoxReader reader)
 {
     base.Read(reader);
       int bufSize = (int)Size - 16; // assume that Size of this box cannot be greater than int.MaxValue (which is a reasonable assumption)
       if (bufSize != (int)((Offset + Size) - (ulong)reader.BaseStream.Position)) // do the addition first, then subtract
     throw new Exception("Byte alignment error in unknown sample entry box");
       byte[] buffer = new byte[bufSize];
       reader.Read(buffer, 0, bufSize);
 }
        public override void Read(BoxReader reader)
        {
            using (new SizeChecker(this, reader))
              {
              base.Read(reader);
              predefined1 = reader.ReadByte(); // must be 01, configurationVersion
              profileIDC = reader.ReadByte(); // AVCProfileIndication
              constraintFlags = reader.ReadByte(); // profile_compatibility
              levelIDC = reader.ReadByte(); // AVCLevelIndication
              nalUnitLengthSizeByte = reader.ReadByte(); // first 6 bits are reserved and set to 1
              nalUnitLengthSize = (byte)((nalUnitLengthSizeByte & 0x3) + 1); // lengthSizeMinusOne

              seqParamCountByte = reader.ReadByte(); // first 3 bits are reserved and set to 1
              seqParamCount = (byte)(seqParamCountByte & 0x1F); // numOfSequenceParameterSets
              SPS = new SequenceParameterSet[seqParamCount];
              for (int i = 0; i < seqParamCount; i++)
              {
                seqParamLength = reader.ReadUInt16();
                seqParamSetData = new byte[seqParamLength];
                reader.Read(seqParamSetData, 0, seqParamSetData.Length);
                SPS[i] = ParseSPS(seqParamSetData);
              }

              picParamCount = reader.ReadByte();
              PPS = new PictureParameterSet[picParamCount];
              for (int i = 0; i < picParamCount; i++) {
                picParamLength = reader.ReadUInt16();
                picParamSetData = new byte[picParamLength];
                reader.Read(picParamSetData, 0, picParamSetData.Length);
                PPS[i] = ParsePPS(picParamSetData);
              }
              }
        }
Example #12
0
 public override void Read(BoxReader reader)
 {
     using (new SizeChecker(this, reader)) {
     base.Read(reader);
     reader.ReadInt32();
     reader.Read(handler_type, 0, 4);
     for (int i = 0; i < 3; i++) reader.ReadUInt32();
     Name = reader.ReadNullTerminatedString();
       // special case to take care of Apple's bug
       // (Apple and GoPro prepends the string with char count, but then adds one byte too many to the box size.)
     if (reader.BaseStream.Position != (long)(this.Size + this.Offset))
     {
     reader.BaseStream.Position = (long)(this.Size + this.Offset);
     Name = Name.Substring(1);
     }
       }
 }
 public override void Read(BoxReader reader)
 {
     using (new SizeChecker(this, reader)) {
     long startpos = reader.BaseStream.Position;
     base.Read(reader);
     long dataLen = (startpos + (long)Size) - reader.BaseStream.Position;
     if (dataLen > 0L) {
       data = new byte[dataLen];
       reader.Read(data, 0, data.Length);
     }
       }
 }
Example #14
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 #15
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];
                }
            }
        }
 public override void Read(BoxReader reader)
 {
     using (new SizeChecker(this, reader))
       {
     long startpos = reader.BaseStream.Position;
     base.Read(reader);
     UserType = reader.ReadExtendedBoxType();
     int contentSize = (int)((long)base.Size - (reader.BaseStream.Position - startpos));
     if (contentSize > 0)
     {
       Contents = new byte[contentSize];
       reader.Read(Contents, 0, contentSize);
     }
       }
 }
Example #17
0
        public override void Read(BoxReader reader)
        {
            using (new SizeChecker(this, reader)) {
            base.Read(reader);
            if (Version == 1) {
              creationTime = reader.ReadUInt64();
              modificationTime = reader.ReadUInt64();
              TimeScale = reader.ReadUInt32();
              Duration = reader.ReadUInt64();
            } else {
              creationTime = (UInt64)reader.ReadUInt32();
              modificationTime = (UInt64)reader.ReadUInt32();
              TimeScale = reader.ReadUInt32();
              Duration = (UInt64)reader.ReadUInt32();
            }

            // Set rate 16.16.
            rate[0] = reader.ReadUInt16();
            rate[1] = reader.ReadUInt16();

            // Set _volume.
            reader.Read(volume, 0, 2);

            reader.ReadInt16(); // bit[16] - reserved = 0
            for (int x = 0; x < 2; x++) reader.ReadUInt32(); // bit(32)[2] - pre_defined = 0
            this.Matrix.Read(reader);
            for (int x = 0; x < 6; x++) reader.ReadUInt32(); // bit(32)[6] - pre_defined = 0

            NextTrackID = reader.ReadUInt32();
              }
        }