Example #1
0
        public override void Read(BoxReader reader)
        {
            using (new SizeChecker(this, reader)) {
                base.Read(reader);
                if (Version == 1)
                {
                    creationTime     = reader.ReadUInt64();
                    modificationTime = reader.ReadUInt64();
                    TrackID          = reader.ReadUInt32();
                    UInt32 reserved = reader.ReadUInt32(); // reserved = 0
                    Duration = reader.ReadUInt64();
                }
                else
                {
                    creationTime     = (UInt32)reader.ReadUInt32();
                    modificationTime = (UInt32)reader.ReadUInt32();
                    TrackID          = reader.ReadUInt32();
                    reader.ReadUInt32(); // reserved = 0
                    Duration = (UInt32)reader.ReadUInt32();
                }

                for (int x = 0; x < 2; x++)
                {
                    reader.ReadUInt32();              // int(32)[2] - reserved = 0  - 40 bytes
                }
                Layer          = reader.ReadUInt16(); // layer = 0
                AlternateGroup = reader.ReadUInt16(); // alternate_group = 0
                _volume        = reader.ReadUInt16();
                reader.ReadUInt16();                  // reserved = 0   -  48 bytes
                this.Matrix.Read(reader);
                _width  = reader.ReadUInt32();
                _height = reader.ReadUInt32();
            }
        }
 public override void Read(BoxReader reader)
 {
     using (new SizeChecker(this, reader))
     {
         base.Read(reader);
         this.TrackId = reader.ReadUInt32();
         if (EnumUtils.IsBitSet <TrackFragmentHeaderBoxFlags>((TrackFragmentHeaderBoxFlags)base.Flags, TrackFragmentHeaderBoxFlags.BaseDataOffsetPresent))
         {
             this._baseDataOffset = reader.ReadUInt64();
         }
         if (EnumUtils.IsBitSet <TrackFragmentHeaderBoxFlags>((TrackFragmentHeaderBoxFlags)base.Flags, TrackFragmentHeaderBoxFlags.SampleDescriptionIndexPresent))
         {
             this._sampleDescriptionIndex = reader.ReadUInt32();
         }
         if (EnumUtils.IsBitSet <TrackFragmentHeaderBoxFlags>((TrackFragmentHeaderBoxFlags)base.Flags, TrackFragmentHeaderBoxFlags.DefaultSampleDurationPresent))
         {
             this._defaultSampleDuration = reader.ReadUInt32();
         }
         if (EnumUtils.IsBitSet <TrackFragmentHeaderBoxFlags>((TrackFragmentHeaderBoxFlags)base.Flags, TrackFragmentHeaderBoxFlags.DefaultSampleSizePresent))
         {
             this._defaultSampleSize = reader.ReadUInt32();
         }
         if (EnumUtils.IsBitSet <TrackFragmentHeaderBoxFlags>((TrackFragmentHeaderBoxFlags)base.Flags, TrackFragmentHeaderBoxFlags.DefaultSampleFlagsPresent))
         {
             this._defaultSampleFlags = reader.ReadUInt32();
         }
     }
 }
Example #3
0
        public virtual void Read(BoxReader reader)
        {
            this.Offset = (ulong)reader.BaseStream.Position;
            this.size   = reader.ReadUInt32();

            if (size == 0)
            {
                this.type = BoxTypes.Error;
                return;
            }

            this.type = reader.ReadBoxType();
            if (this.size == 1)
            {
                this.largeSize = reader.ReadUInt64();
            }
            if (this.expectedType == BoxTypes.Any)
            {
                reader.BaseStream.Seek((long)(this.size - 8), SeekOrigin.Current);
            }
            else if (this.expectedType == BoxTypes.AnyDescription)
            {
                return;
            }
            else if (this.type != this.expectedType)
            {
                throw new UnexpectedBoxException(this.expectedType, this.type);
            }
        }
 public override void Read(BoxReader reader)
 {
     using (new SizeChecker(this, reader)) {
     base.Read(reader);
     if (Version == 1) {
       FragmentDuration = reader.ReadUInt64();
     } else {
       FragmentDuration = (UInt64)reader.ReadUInt32();
     }
       }
 }
Example #5
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)
 {
     using (new SizeChecker(this, reader)) {
         base.Read(reader);
         if (Version == 1)
         {
             FragmentDuration = reader.ReadUInt64();
         }
         else
         {
             FragmentDuration = (UInt64)reader.ReadUInt32();
         }
     }
 }
Example #7
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     = (UInt32)reader.ReadUInt32();
                    modificationTime = (UInt32)reader.ReadUInt32();
                    TimeScale        = reader.ReadUInt32();
                    Duration         = (UInt32)reader.ReadUInt32();
                }

                language = reader.ReadUInt16();
                reader.ReadUInt16(); // pre_defined = 0
            }
        }
Example #8
0
 public override void Read(BoxReader reader)
 {
     using (new SizeChecker(this, reader))
     {
         base.Read(reader);
         entryCount = reader.ReadUInt32();
         editList   = new EditList[entryCount];
         for (int i = 0; i < entryCount; i++)
         {
             if (Version == 0)
             {
                 editList[i].segmentDuration = reader.ReadUInt32();
                 editList[i].mediaTime       = reader.ReadInt32();
             }
             else // must be 1
             {
                 editList[i].segmentDuration = reader.ReadUInt64();
                 editList[i].mediaTime       = reader.ReadInt64();
             }
             editList[i].mediaRateInteger  = (short)reader.ReadInt16();
             editList[i].mediaRateFraction = (short)reader.ReadInt16();
         }
     }
 }
        public void Read(BoxReader reader, byte version, uint LengthSizeOfTrafNum, uint LengthSizeOfTrunNum, uint LengthSizeOfSampleNum)
        {
            if (version == 1)
            {
              ulong tmpTime = reader.ReadUInt64();
            //              if (tmpTime < LastTime) BaseTime = LastTime;
                this.Time = BaseTime + tmpTime;
                this.MoofOffset = reader.ReadUInt64();
                LastTime = Time;
            }
            else
            {
                this.Time = reader.ReadUInt32();
                this.MoofOffset = reader.ReadUInt32();
            }

            switch (((LengthSizeOfTrafNum + 1) * 8))
            {
                case 0x18:
                    this.TrafNumber = reader.ReadUInt24();
                    break;

                case 0x20:
                    this.TrafNumber = reader.ReadUInt32();
                    break;

                case 8:
                    this.TrafNumber = reader.ReadByte();
                    break;

                case 0x10:
                    this.TrafNumber = reader.ReadUInt16();
                    break;
            }

            switch (((LengthSizeOfTrunNum + 1) * 8))
            {
                case 0x18:
                    this.TrunNumber = reader.ReadUInt24();
                    break;

                case 0x20:
                    this.TrunNumber = reader.ReadUInt32();
                    break;

                case 8:
                    this.TrunNumber = reader.ReadByte();
                    break;

                case 0x10:
                    this.TrunNumber = reader.ReadUInt16();
                    break;
            }

            switch (((LengthSizeOfSampleNum + 1) * 8))
            {
                case 8:
                    this.SampleNumber = reader.ReadByte();
                    return;

                case 0x10:
                    this.SampleNumber = reader.ReadUInt16();
                    break;

                case 0x18:
                    this.SampleNumber = reader.ReadUInt24();
                    return;

                case 0x20:
                    this.SampleNumber = reader.ReadUInt32();
                    return;
            }
        }
Example #10
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 = (UInt32)reader.ReadUInt32();
              modificationTime = (UInt32)reader.ReadUInt32();
              TimeScale = reader.ReadUInt32();
              Duration = (UInt32)reader.ReadUInt32();
            }

            language = reader.ReadUInt16();
            reader.ReadUInt16(); // pre_defined = 0
              }
        }
 public override void Read(BoxReader reader)
 {
     using (new SizeChecker(this, reader))
     {
       base.Read(reader);
       this.TrackId = reader.ReadUInt32();
       if (EnumUtils.IsBitSet<TrackFragmentHeaderBoxFlags>((TrackFragmentHeaderBoxFlags)base.Flags, TrackFragmentHeaderBoxFlags.BaseDataOffsetPresent))
       {
           this._baseDataOffset = reader.ReadUInt64();
       }
       if (EnumUtils.IsBitSet<TrackFragmentHeaderBoxFlags>((TrackFragmentHeaderBoxFlags)base.Flags, TrackFragmentHeaderBoxFlags.SampleDescriptionIndexPresent))
       {
           this._sampleDescriptionIndex = reader.ReadUInt32();
       }
       if (EnumUtils.IsBitSet<TrackFragmentHeaderBoxFlags>((TrackFragmentHeaderBoxFlags) base.Flags, TrackFragmentHeaderBoxFlags.DefaultSampleDurationPresent)) {
           this._defaultSampleDuration = reader.ReadUInt32();
       }
       if (EnumUtils.IsBitSet<TrackFragmentHeaderBoxFlags>((TrackFragmentHeaderBoxFlags) base.Flags, TrackFragmentHeaderBoxFlags.DefaultSampleSizePresent)) {
           this._defaultSampleSize = reader.ReadUInt32();
       }
       if (EnumUtils.IsBitSet<TrackFragmentHeaderBoxFlags>((TrackFragmentHeaderBoxFlags) base.Flags, TrackFragmentHeaderBoxFlags.DefaultSampleFlagsPresent)) {
           this._defaultSampleFlags = reader.ReadUInt32();
       }
     }
 }
Example #12
0
        public override void Read(BoxReader reader)
        {
            using (new SizeChecker(this, reader)) {
            base.Read(reader);
            if (Version == 1) {
              creationTime = reader.ReadUInt64();
              modificationTime = reader.ReadUInt64();
              TrackID = reader.ReadUInt32();
              UInt32 reserved = reader.ReadUInt32(); // reserved = 0
              Duration = reader.ReadUInt64();
            } else {
              creationTime = (UInt32)reader.ReadUInt32();
              modificationTime = (UInt32)reader.ReadUInt32();
              TrackID = reader.ReadUInt32();
              reader.ReadUInt32(); // reserved = 0
              Duration = (UInt32)reader.ReadUInt32();
            }

            for (int x = 0; x < 2; x++) reader.ReadUInt32(); // int(32)[2] - reserved = 0  - 40 bytes
            Layer = reader.ReadUInt16(); // layer = 0
            AlternateGroup = reader.ReadUInt16(); // alternate_group = 0
            _volume = reader.ReadUInt16();
            reader.ReadUInt16(); // reserved = 0   -  48 bytes
            this.Matrix.Read(reader);
            _width = reader.ReadUInt32();
            _height = reader.ReadUInt32();
              }
        }
Example #13
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();
              }
        }
Example #14
0
        public virtual void Read(BoxReader reader)
        {
            this.Offset = (ulong)reader.BaseStream.Position;
            this.size = reader.ReadUInt32();

            if (size == 0) {
              this.type = BoxTypes.Error;
              return;
            }

            this.type = reader.ReadBoxType();
            if (this.size == 1) {
              this.largeSize = reader.ReadUInt64();
            }
            if (this.expectedType == BoxTypes.Any)
            {
                reader.BaseStream.Seek((long) (this.size - 8), SeekOrigin.Current);
            }
            else if (this.expectedType == BoxTypes.AnyDescription)
            {
                return;
            }
            else if (this.type != this.expectedType)
            {
              throw new UnexpectedBoxException(this.expectedType, this.type);
            }
        }
Example #15
0
        public void Read(BoxReader reader, byte version, uint LengthSizeOfTrafNum, uint LengthSizeOfTrunNum, uint LengthSizeOfSampleNum)
        {
            if (version == 1)
            {
                ulong tmpTime = reader.ReadUInt64();
//              if (tmpTime < LastTime) BaseTime = LastTime;
                this.Time       = BaseTime + tmpTime;
                this.MoofOffset = reader.ReadUInt64();
                LastTime        = Time;
            }
            else
            {
                this.Time       = reader.ReadUInt32();
                this.MoofOffset = reader.ReadUInt32();
            }

            switch (((LengthSizeOfTrafNum + 1) * 8))
            {
            case 0x18:
                this.TrafNumber = reader.ReadUInt24();
                break;

            case 0x20:
                this.TrafNumber = reader.ReadUInt32();
                break;

            case 8:
                this.TrafNumber = reader.ReadByte();
                break;

            case 0x10:
                this.TrafNumber = reader.ReadUInt16();
                break;
            }

            switch (((LengthSizeOfTrunNum + 1) * 8))
            {
            case 0x18:
                this.TrunNumber = reader.ReadUInt24();
                break;

            case 0x20:
                this.TrunNumber = reader.ReadUInt32();
                break;

            case 8:
                this.TrunNumber = reader.ReadByte();
                break;

            case 0x10:
                this.TrunNumber = reader.ReadUInt16();
                break;
            }

            switch (((LengthSizeOfSampleNum + 1) * 8))
            {
            case 8:
                this.SampleNumber = reader.ReadByte();
                return;

            case 0x10:
                this.SampleNumber = reader.ReadUInt16();
                break;

            case 0x18:
                this.SampleNumber = reader.ReadUInt24();
                return;

            case 0x20:
                this.SampleNumber = reader.ReadUInt32();
                return;
            }
        }
Example #16
0
 public override void Read(BoxReader reader)
 {
     using (new SizeChecker(this, reader))
       {
     base.Read(reader);
     entryCount = reader.ReadUInt32();
     editList = new EditList[entryCount];
     for (int i = 0; i < entryCount; i++)
     {
       if (Version == 0)
       {
     editList[i].segmentDuration = reader.ReadUInt32();
     editList[i].mediaTime = reader.ReadInt32();
       }
       else // must be 1
       {
     editList[i].segmentDuration = reader.ReadUInt64();
     editList[i].mediaTime = reader.ReadInt64();
       }
       editList[i].mediaRateInteger = (short)reader.ReadInt16();
       editList[i].mediaRateFraction = (short)reader.ReadInt16();
     }
       }
 }