Esempio n. 1
0
 /// <summary>
 /// Reads the full box properties from stream.
 /// </summary>
 /// <param name="reader">The binary reader with the stream.</param>
 protected override void ReadFullBoxPropertiesFromStream(BoxBinaryReader reader)
 {
     if (this.Version == 0)
     {
         this.CreationTime     = Converter.SecondsOffsetToDateTimeUtc(reader.ReadUInt32());
         this.ModificationTime = Converter.SecondsOffsetToDateTimeUtc(reader.ReadUInt32());
         this.TrackId          = reader.ReadUInt32();
         reserved1             = reader.ReadUInt32();
         this.Duration         = reader.ReadUInt32();
     }
     else
     {
         this.CreationTime     = Converter.SecondsOffsetToDateTimeUtc(reader.ReadUInt64());
         this.ModificationTime = Converter.SecondsOffsetToDateTimeUtc(reader.ReadUInt64());
         this.TrackId          = reader.ReadUInt32();
         reserved1             = reader.ReadUInt32();
         this.Duration         = reader.ReadUInt64();
     }
     reader.Read(reserved2, 0, 8);
     this.Layer          = reader.ReadUInt16();
     this.AlternateGroup = reader.ReadUInt16();
     this.Volume         = reader.ReadUInt16();
     reserved3           = reader.ReadUInt16();
     for (int i = 0; i < 9; i++)
     {
         matrix[i] = reader.ReadUInt32();
     }
     this.Width  = reader.ReadUInt32();
     this.Height = reader.ReadUInt32();
 }
        /// <summary>
        /// Reads the full box properties from stream.
        /// </summary>
        /// <param name="reader">The binary reader with the stream.</param>
        protected override void ReadFullBoxPropertiesFromStream(BoxBinaryReader reader)
        {          
            if (base.Version == 0)
            {
                this.CreationTimeUtc = Converter.SecondsOffsetToDateTimeUtc(reader.ReadUInt32());
                this.ModificationTimeUtc = Converter.SecondsOffsetToDateTimeUtc(reader.ReadUInt32());
                this.TimeScale = reader.ReadUInt32();
                this.Duration = reader.ReadUInt32();
            }
            else
            {
                this.CreationTimeUtc = Converter.SecondsOffsetToDateTimeUtc(reader.ReadUInt64());
                this.ModificationTimeUtc = Converter.SecondsOffsetToDateTimeUtc(reader.ReadUInt64());
                this.TimeScale = reader.ReadUInt32();
                this.Duration = reader.ReadUInt64();
            }

            this.Rate = reader.ReadUInt32();
            this.Volume = reader.ReadUInt16();
            reader.Read(reserved1, 0, reserved1.Length);
            reader.Read(reserved2, 0, reserved2.Length);
            for (int i = 0; i < 9; i++)
            {
                matrix[i] = reader.ReadUInt32();
            }
            reader.Read(predefined, 0, predefined.Length);
            this.NextTrackId = reader.ReadUInt32();

        }
        /// <summary>
        /// Reads the full box properties from stream.
        /// </summary>
        /// <param name="reader">The binary reader with the stream.</param>
        protected override void ReadFullBoxPropertiesFromStream(BoxBinaryReader reader)
        {
            this.TrackId = reader.ReadUInt32();

            uint num = reader.ReadUInt32();

            this.reserved              = ((int)(num >> 6)) & 0x3ffffff;
            this.LengthSizeOfTrafNum   = (byte)((num >> 4) & 3);
            this.LengthSizeOfTrunNum   = (byte)((num >> 2) & 3);
            this.LengthSizeOfSampleNum = (byte)(num & 3);

            this.NumberOfEntry = reader.ReadUInt32();

            for (int i = 0; i < this.NumberOfEntry; i++)
            {
                TrackFragmentRandomAccessEntry entry = new TrackFragmentRandomAccessEntry();

                if (base.Version == 1)
                {
                    entry.Time       = reader.ReadUInt64();
                    entry.MoofOffset = reader.ReadUInt64();
                }
                else
                {
                    entry.Time       = reader.ReadUInt32();
                    entry.MoofOffset = reader.ReadUInt32();
                }

                entry.TrafNumber   = ReadIntValueFromBytes(reader, this.LengthSizeOfTrafNum);
                entry.TrunNumber   = ReadIntValueFromBytes(reader, this.LengthSizeOfTrunNum);
                entry.SampleNumber = ReadIntValueFromBytes(reader, this.LengthSizeOfSampleNum);

                this.TrackFragmentRandomAccessEntries.Add(entry);
            }
        }
        /// <summary>
        /// Reads the full box properties from stream.
        /// </summary>
        /// <param name="reader">The binary reader with the stream.</param>
        protected override void ReadFullBoxPropertiesFromStream(BoxBinaryReader reader)
        {
            if (base.Version == 0)
            {
                this.CreationTimeUtc     = Converter.SecondsOffsetToDateTimeUtc(reader.ReadUInt32());
                this.ModificationTimeUtc = Converter.SecondsOffsetToDateTimeUtc(reader.ReadUInt32());
                this.TimeScale           = reader.ReadUInt32();
                this.Duration            = reader.ReadUInt32();
            }
            else
            {
                this.CreationTimeUtc     = Converter.SecondsOffsetToDateTimeUtc(reader.ReadUInt64());
                this.ModificationTimeUtc = Converter.SecondsOffsetToDateTimeUtc(reader.ReadUInt64());
                this.TimeScale           = reader.ReadUInt32();
                this.Duration            = reader.ReadUInt64();
            }

            this.Rate   = reader.ReadUInt32();
            this.Volume = reader.ReadUInt16();
            reader.Read(reserved1, 0, reserved1.Length);
            reader.Read(reserved2, 0, reserved2.Length);
            for (int i = 0; i < 9; i++)
            {
                matrix[i] = reader.ReadUInt32();
            }
            reader.Read(predefined, 0, predefined.Length);
            this.NextTrackId = reader.ReadUInt32();
        }
        /// <summary>
        /// Reads the full box properties from stream.
        /// </summary>
        /// <param name="reader">The binary reader with the stream.</param>
        protected override void ReadFullBoxPropertiesFromStream(BoxBinaryReader reader)
        {
            this.TrackId = reader.ReadUInt32();
            
            uint num = reader.ReadUInt32();
            this.reserved = ((int)(num >> 6)) & 0x3ffffff;
            this.LengthSizeOfTrafNum = (byte)((num >> 4) & 3);
            this.LengthSizeOfTrunNum = (byte)((num >> 2) & 3);
            this.LengthSizeOfSampleNum = (byte)(num & 3);

            this.NumberOfEntry = reader.ReadUInt32();

            for (int i = 0; i < this.NumberOfEntry; i++)
            {
                TrackFragmentRandomAccessEntry entry = new TrackFragmentRandomAccessEntry();
                
                if (base.Version == 1)
                {
                    entry.Time = reader.ReadUInt64();
                    entry.MoofOffset = reader.ReadUInt64();
                }
                else
                {
                    entry.Time = reader.ReadUInt32();
                    entry.MoofOffset = reader.ReadUInt32();
                }

                entry.TrafNumber = ReadIntValueFromBytes(reader, this.LengthSizeOfTrafNum);
                entry.TrunNumber = ReadIntValueFromBytes(reader, this.LengthSizeOfTrunNum);
                entry.SampleNumber = ReadIntValueFromBytes(reader, this.LengthSizeOfSampleNum);
                               
                this.TrackFragmentRandomAccessEntries.Add(entry);
            }
        }
        /// <summary>
        /// Reads the box properties from stream.
        /// </summary>
        /// <param name="reader">The binary reader with the stream.</param>
        protected override void ReadFullBoxPropertiesFromStream(BoxBinaryReader reader)
        {
            this.ReferenceTrackID = reader.ReadUInt32();
            this.NtpTimestamp     = reader.ReadUInt64();

            if (this.Version == 0)
            {
                this.MediaTime = reader.ReadUInt32();
            }
            else
            {
                this.MediaTime = reader.ReadUInt64();
            }
        }
        /// <summary>
        /// Reads the box properties from stream.
        /// </summary>
        /// <param name="reader">The binary reader with the stream.</param>
        protected override void ReadFullBoxPropertiesFromStream(BoxBinaryReader reader)
        {
            this.ReferenceTrackID = reader.ReadUInt32();
            this.NtpTimestamp = reader.ReadUInt64();

            if (this.Version == 0)
            {
                this.MediaTime = reader.ReadUInt32();
            }
            else
            {
                this.MediaTime = reader.ReadUInt64();
            }
        }
        /// <summary>
        /// Reads the full box properties from stream.
        /// </summary>
        /// <param name="reader">The binary reader with the stream.</param>
        protected override void ReadFullBoxPropertiesFromStream(BoxBinaryReader reader)
        {
            var sampleCount = reader.ReadUInt32();
            this.samples = new Sample[sampleCount];

            for (int i = 0; i < sampleCount; i++)
            {
                // TODO: Figure out the iv_size to read this value correctly.
                ulong initializationVector = reader.ReadUInt64();
                SubSample[] subSamples;

                if ((this.Flags & 0x02) == 0x02)
                {
                    var subSampleCount = reader.ReadUInt16();
                    subSamples = new SubSample[subSampleCount];

                    for (int j = 0; j < subSampleCount; j++)
                    {
                        subSamples[j] = new SubSample(
                            reader.ReadUInt16(),
                            reader.ReadUInt32());
                    }
                }
                else
                {
                    subSamples = new SubSample[0];
                }

                this.samples[i] = new Sample(initializationVector, subSamples);
            }
        }
Esempio n. 9
0
        internal void ReadBoxFromStream(BoxBinaryReader reader)
        {
            if (this.Size == 0)
            {
                throw new BoxException("Zero size not supported!");
            }

            if (this.Size == 1)
            {
                this.Size = (long)reader.ReadUInt64();
            }

            ReadBoxPropertiesFromStream(reader);

            if (reader.Offset != this.Size + this.Offset)
            {
                string message = string.Format("The box was not totally read from the stream.\n\tBox Type: {0}, Reader Offset: {1}, Box Size: {2}, Box Offset {3}",
                                               this.GetType().Name, reader.Offset, this.Size, this.Offset);

#if DEBUG
                System.Diagnostics.Debug.WriteLine(message);
#endif
                reader.GotoEndOfBox(this.Offset, this.Size);
            }
        }
        /// <summary>
        /// Reads the full box properties from stream.
        /// </summary>
        /// <param name="reader">The binary reader with the stream.</param>
        protected override void ReadFullBoxPropertiesFromStream(BoxBinaryReader reader)
        {
            var sampleCount = reader.ReadUInt32();

            this.samples = new Sample[sampleCount];

            for (int i = 0; i < sampleCount; i++)
            {
                // TODO: Figure out the iv_size to read this value correctly.
                ulong       initializationVector = reader.ReadUInt64();
                SubSample[] subSamples;

                if ((this.Flags & 0x02) == 0x02)
                {
                    var subSampleCount = reader.ReadUInt16();
                    subSamples = new SubSample[subSampleCount];

                    for (int j = 0; j < subSampleCount; j++)
                    {
                        subSamples[j] = new SubSample(
                            reader.ReadUInt16(),
                            reader.ReadUInt32());
                    }
                }
                else
                {
                    subSamples = new SubSample[0];
                }

                this.samples[i] = new Sample(initializationVector, subSamples);
            }
        }
        protected override void ReadFullBoxPropertiesFromStream(BoxBinaryReader reader)
        {
            this.ReferenceId = reader.ReadUInt32();
            this.Timescale = reader.ReadUInt32();

            if (this.Version == 1)
            {
                this.EarliestPresentationTime = reader.ReadUInt64();
                this.FirstOffset = reader.ReadUInt64();
            }
            else
            {
                this.EarliestPresentationTime = reader.ReadUInt32();
                this.FirstOffset = reader.ReadUInt32();
            }

            this.Reserved = reader.ReadUInt16();
            this.ReferenceCount = reader.ReadUInt16();

            Subsegments = new List<Subsegment>();
            for (int i = 0; i < this.ReferenceCount; i++)
            {
                var subsegment = new Subsegment();

                uint referenceNum = reader.ReadUInt32();
                subsegment.ReferenceType = System.Convert.ToBoolean(referenceNum >> 31); // 1 bit
                subsegment.ReferencedSize = (referenceNum << 1) >> 1; // 31 bits

                subsegment.Duration = reader.ReadUInt32();

                uint sapNum = reader.ReadUInt32();
                subsegment.StartsWithSAP = System.Convert.ToBoolean(sapNum >> 31); // 1 bit
                subsegment.SAPType = System.Convert.ToUInt16((sapNum << 1) >> 29); // 3 bits
                subsegment.SAPDeltaTime = (sapNum << 4) >> 4; // 28 bits

                Subsegments.Add(subsegment);
            }

            reader.GotoEndOfBox(Offset, Size);
        }
Esempio n. 12
0
        protected override void ReadFullBoxPropertiesFromStream(BoxBinaryReader reader)
        {
            this.ReferenceId = reader.ReadUInt32();
            this.Timescale   = reader.ReadUInt32();

            if (this.Version == 1)
            {
                this.EarliestPresentationTime = reader.ReadUInt64();
                this.FirstOffset = reader.ReadUInt64();
            }
            else
            {
                this.EarliestPresentationTime = reader.ReadUInt32();
                this.FirstOffset = reader.ReadUInt32();
            }

            this.Reserved       = reader.ReadUInt16();
            this.ReferenceCount = reader.ReadUInt16();

            Subsegments = new List <Subsegment>();
            for (int i = 0; i < this.ReferenceCount; i++)
            {
                var subsegment = new Subsegment();

                uint referenceNum = reader.ReadUInt32();
                subsegment.ReferenceType  = System.Convert.ToBoolean(referenceNum >> 31); // 1 bit
                subsegment.ReferencedSize = (referenceNum << 1) >> 1;                     // 31 bits

                subsegment.Duration = reader.ReadUInt32();

                uint sapNum = reader.ReadUInt32();
                subsegment.StartsWithSAP = System.Convert.ToBoolean(sapNum >> 31);       // 1 bit
                subsegment.SAPType       = System.Convert.ToUInt16((sapNum << 1) >> 29); // 3 bits
                subsegment.SAPDeltaTime  = (sapNum << 4) >> 4;                           // 28 bits

                Subsegments.Add(subsegment);
            }

            reader.GotoEndOfBox(Offset, Size);
        }
Esempio n. 13
0
        protected ulong ReadBoxSize(BoxBinaryReader reader)
        {
            ulong size = 0;

            size = reader.ReadUInt32();

            if (size == 1)
            {
                reader.BaseStream.Seek(4, SeekOrigin.Current);  // Skip over the box type
                size = reader.ReadUInt64();
            }

            return(size);
        }
        /// <summary>
        /// Reads the full box properties from stream.
        /// </summary>
        /// <param name="reader">The binary reader with the stream.</param>
        protected override void ReadFullBoxPropertiesFromStream(BoxBinaryReader reader)
        {
            if (this.Version == 1)
            {
                reader.BaseStream.Seek(16, System.IO.SeekOrigin.Current);
                this.Timescale = reader.ReadUInt32();
                this.Duration = reader.ReadUInt64();
            }
            else
            {
                reader.BaseStream.Seek(8, System.IO.SeekOrigin.Current);
                this.Timescale = reader.ReadUInt32();
                this.Duration = reader.ReadUInt32();
            }

            this.Language = reader.ReadUInt16PackedCharacters();

            reader.GotoEndOfBox(Offset, Size);
        }
Esempio n. 15
0
        /// <summary>
        /// Reads the full box properties from stream.
        /// </summary>
        /// <param name="reader">The binary reader with the stream.</param>
        protected override void ReadFullBoxPropertiesFromStream(BoxBinaryReader reader)
        {
            if (this.Version == 1)
            {
                reader.BaseStream.Seek(16, System.IO.SeekOrigin.Current);
                this.Timescale = reader.ReadUInt32();
                this.Duration  = reader.ReadUInt64();
            }
            else
            {
                reader.BaseStream.Seek(8, System.IO.SeekOrigin.Current);
                this.Timescale = reader.ReadUInt32();
                this.Duration  = reader.ReadUInt32();
            }

            this.Language = reader.ReadUInt16PackedCharacters();

            reader.GotoEndOfBox(Offset, Size);
        }
        /// <summary>
        /// Reads the box properties from stream.
        /// </summary>
        /// <param name="reader">The binary reader with the stream.</param>
        protected override void ReadFullBoxPropertiesFromStream(BoxBinaryReader reader)
        {
            if ((this.Flags & 1) != 0)
            {
                this.AuxInfoType = reader.ReadUInt32();
                this.AuxInfoTypeParameter = reader.ReadUInt32();
            }

            this.EntryCount = reader.ReadUInt32();
            this.Offsets = new ulong[this.EntryCount];

            for (var i = 0; i < this.EntryCount; i++)
            {
                if (this.Version == 0)
                {
                    this.Offsets[i] = reader.ReadUInt32();
                }
                else
                {
                    this.Offsets[i] = reader.ReadUInt64();
                }
            }
        }
Esempio n. 17
0
        /// <summary>
        /// Reads the box properties from stream.
        /// </summary>
        /// <param name="reader">The binary reader with the stream.</param>
        protected override void ReadFullBoxPropertiesFromStream(BoxBinaryReader reader)
        {
            if ((this.Flags & 1) != 0)
            {
                this.AuxInfoType          = reader.ReadUInt32();
                this.AuxInfoTypeParameter = reader.ReadUInt32();
            }

            this.EntryCount = reader.ReadUInt32();
            this.Offsets    = new ulong[this.EntryCount];

            for (var i = 0; i < this.EntryCount; i++)
            {
                if (this.Version == 0)
                {
                    this.Offsets[i] = reader.ReadUInt32();
                }
                else
                {
                    this.Offsets[i] = reader.ReadUInt64();
                }
            }
        }
 /// <summary>
 /// Reads the full box properties from stream.
 /// </summary>
 /// <param name="reader">The binary reader with the stream.</param>
 protected override void ReadFullBoxPropertiesFromStream(BoxBinaryReader reader)
 {
     this.TrackId = reader.ReadUInt32();
     if ((base.Flags & 1) != 0)
     {
         this.BaseDataOffset = reader.ReadUInt64();
     }
     if ((base.Flags & 2) != 0)
     {
         this.SampleDescriptionIndex = reader.ReadUInt32();
     }
     if ((base.Flags & 8) != 0)
     {
         this.DefaultSampleDuration = reader.ReadUInt32();
     }
     if ((base.Flags & 0x10) != 0)
     {
         this.DefaultSampleSize = reader.ReadUInt32();
     }
     if ((base.Flags & 0x20) != 0)
     {
         this.DefaultSampleFlags = reader.ReadUInt32();
     }
 }
 /// <summary>
 /// Reads the full box properties from stream.
 /// </summary>
 /// <param name="reader">The binary reader with the stream.</param>
 protected override void ReadFullBoxPropertiesFromStream(BoxBinaryReader reader)
 {
     this.TrackId = reader.ReadUInt32();
     if ((base.Flags & 1) != 0)
     {
         this.BaseDataOffset = reader.ReadUInt64();
     }
     if ((base.Flags & 2) != 0)
     {
         this.SampleDescriptionIndex = reader.ReadUInt32();
     }
     if ((base.Flags & 8) != 0)
     {
         this.DefaultSampleDuration = reader.ReadUInt32();
     }
     if ((base.Flags & 0x10) != 0)
     {
         this.DefaultSampleSize = reader.ReadUInt32();
     }
     if ((base.Flags & 0x20) != 0)
     {
         this.DefaultSampleFlags = reader.ReadUInt32();
     }
 }
Esempio n. 20
0
        internal void ReadBoxFromStream(BoxBinaryReader reader)
        {
            if (this.Size == 0)
            {
                throw new BoxException("Zero size not supported!");
            }

            if (this.Size == 1)
            {
                this.Size = (long)reader.ReadUInt64();
            }

            ReadBoxPropertiesFromStream(reader);
            
            if (reader.Offset != this.Size + this.Offset)
            {
                string message = string.Format("The box was not totally read from the stream.\n\tBox Type: {0}, Reader Offset: {1}, Box Size: {2}, Box Offset {3}",
                    this.GetType().Name, reader.Offset, this.Size, this.Offset);

#if DEBUG
                System.Diagnostics.Debug.WriteLine(message);
#endif
                reader.GotoEndOfBox(this.Offset, this.Size);
            }
        }
 /// <summary>
 /// Reads the full box properties from stream.
 /// </summary>
 /// <param name="reader">The binary reader with the stream.</param>
 protected override void ReadFullBoxPropertiesFromStream(BoxBinaryReader reader)
 {
     
     if (this.Version == 0)
     {
         this.CreationTime = Converter.SecondsOffsetToDateTimeUtc(reader.ReadUInt32());
         this.ModificationTime = Converter.SecondsOffsetToDateTimeUtc(reader.ReadUInt32());
         this.TrackId = reader.ReadUInt32();
         reserved1 = reader.ReadUInt32();
         this.Duration = reader.ReadUInt32();
     }
     else
     {
         this.CreationTime = Converter.SecondsOffsetToDateTimeUtc(reader.ReadUInt64());
         this.ModificationTime = Converter.SecondsOffsetToDateTimeUtc(reader.ReadUInt64());
         this.TrackId = reader.ReadUInt32();
         reserved1 = reader.ReadUInt32();
         this.Duration = reader.ReadUInt64();
     }
     reader.Read(reserved2, 0, 8);
     this.Layer = reader.ReadUInt16();
     this.AlternateGroup = reader.ReadUInt16();
     this.Volume = reader.ReadUInt16();
     reserved3 = reader.ReadUInt16();
     for (int i = 0; i < 9; i++)
     {
         matrix[i] = reader.ReadUInt32();
     }
     this.Width = reader.ReadUInt32();
     this.Height = reader.ReadUInt32();
 }