コード例 #1
0
        /// <summary>
        /// Reads the sample entry properties from stream.
        /// </summary>
        /// <param name="reader">The stream reader.</param>
        internal override void ReadSampleEntryPropertiesFromStream(BoxBinaryReader reader)
        {
            predefined1          = reader.ReadUInt16();
            reserved1            = reader.ReadUInt16();
            predefined2          = reader.ReadBytes(12);
            this.Width           = reader.ReadUInt16();
            this.Height          = reader.ReadUInt16();
            this.HorizResolution = reader.ReadUInt32();
            this.VertResolution  = reader.ReadUInt32();
            reserved2            = reader.ReadUInt32();
            this.FrameCount      = reader.ReadUInt16();

            byte[] buffer = new byte[0x20];
            reader.Read(buffer, 0, 0x20);
            int count = buffer[0];

            if (count < 0x20)
            {
                this.CompressorName = Encoding.UTF8.GetString(buffer, 1, count);
            }
            this.Depth  = reader.ReadUInt16();
            predefined3 = reader.ReadUInt16();

            if (reader.PeekNextBoxType() != BoxType.Null)
            {
                ReadInnerBoxes(reader, BoxType.Esds, BoxType.Avcc, BoxType.Avc1, BoxType.Dvc1, BoxType.Btrt, BoxType.Sinf);
                this.VideoCodecData = GetVideoCodecDataFromInnerBoxes();
            }
            else
            {
                var videoInfoHeader = new VideoInfoHeader2(reader);
                this.VideoCodecData = new VideoTrackCodecData(videoInfoHeader);
            }
        }
コード例 #2
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)
        {
            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);
            }
        }
コード例 #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Rectangle"/> class.
 /// </summary>
 /// <param name="reader">The box binary reader.</param>
 public Rectangle(BoxBinaryReader reader)
 {
     this.Left = reader.ReadUInt32();
     this.Top = reader.ReadUInt32();
     this.Right = reader.ReadUInt32();
     this.Bottom = reader.ReadUInt32();
 }
コード例 #4
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)
        {
            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);
            }
        }
コード例 #5
0
ファイル: Rectangle.cs プロジェクト: hyuckry/playerframework
 /// <summary>
 /// Initializes a new instance of the <see cref="Rectangle"/> class.
 /// </summary>
 /// <param name="reader">The box binary reader.</param>
 public Rectangle(BoxBinaryReader reader)
 {
     this.Left   = reader.ReadUInt32();
     this.Top    = reader.ReadUInt32();
     this.Right  = reader.ReadUInt32();
     this.Bottom = 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);
            }
        }
コード例 #7
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)
        {
            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);
            }
        }
コード例 #8
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();
 }
コード例 #9
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)
 {
     OffsetCount = reader.ReadUInt32();
     for (int i = 0; i < OffsetCount; i++)
     {
         Offsets.Add(reader.ReadUInt32());
     }
 }
コード例 #10
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)
 {
     OffsetCount = reader.ReadUInt32();
     for (int i = 0; i < OffsetCount; i++)
     {
         Offsets.Add(reader.ReadUInt32());
     }
 }
コード例 #11
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)
 {
     Count = reader.ReadUInt32();
     for (int i = 0; i < Count; i++)
     {
         var entry = new DecodingTimeToSampleFullBoxEntry(reader.ReadUInt32(), reader.ReadUInt32());
         Entries.Add(entry);
     }
 }
コード例 #12
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)
 {
     Count = reader.ReadUInt32();
     for (int i = 0; i < Count; i++)
     {
         var entry = new DecodingTimeToSampleFullBoxEntry(reader.ReadUInt32(), reader.ReadUInt32());
         Entries.Add(entry);
     }
 }
コード例 #13
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)
        {
            predefined       = reader.ReadUInt32();
            this.HandlerType = new string(reader.ReadChars(4));

            reserved[0] = reader.ReadUInt32();
            reserved[1] = reader.ReadUInt32();
            reserved[2] = reader.ReadUInt32();

            this.Name = reader.ReadNullTerminatedString();
        }
コード例 #14
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)
        {
            predefined = reader.ReadUInt32();
            this.HandlerType = new string(reader.ReadChars(4));
            
            reserved[0] = reader.ReadUInt32();
            reserved[1] = reader.ReadUInt32();
            reserved[2] = reader.ReadUInt32();

            this.Name = reader.ReadNullTerminatedString();
        }
コード例 #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)
 {
     ConstantSize = reader.ReadUInt32();
     SizeCount = reader.ReadUInt32();
     if (ConstantSize == 0)
     {
         for (int i = 0; i < SizeCount; i++)
         {
             SizeTable.Add(reader.ReadUInt32());
         }
     }
 }
コード例 #16
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)
 {
     ConstantSize = reader.ReadUInt32();
     SizeCount    = reader.ReadUInt32();
     if (ConstantSize == 0)
     {
         for (int i = 0; i < SizeCount; i++)
         {
             SizeTable.Add(reader.ReadUInt32());
         }
     }
 }
コード例 #17
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)
        {
            this.GroupingType = reader.ReadUInt32();
            this.EntryCount = reader.ReadUInt32();

            for (var i = 0; i < this.EntryCount; i++)
            {
                uint sampleCount = reader.ReadUInt32();
                uint groupDescriptionIndex = reader.ReadUInt32();

                this.Entries.Add(new SampleToGroupFullBoxEntry(sampleCount, groupDescriptionIndex));
            }
        }
コード例 #18
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)
        {
            this.GroupingType = reader.ReadUInt32();
            this.EntryCount   = reader.ReadUInt32();

            for (var i = 0; i < this.EntryCount; i++)
            {
                uint sampleCount           = reader.ReadUInt32();
                uint groupDescriptionIndex = reader.ReadUInt32();

                this.Entries.Add(new SampleToGroupFullBoxEntry(sampleCount, groupDescriptionIndex));
            }
        }
コード例 #19
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)
        {
            this.ReferenceTrackID = reader.ReadUInt32();
            this.NtpTimestamp = reader.ReadUInt64();

            if (this.Version == 0)
            {
                this.MediaTime = reader.ReadUInt32();
            }
            else
            {
                this.MediaTime = reader.ReadUInt64();
            }
        }
コード例 #20
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)
        {
            this.ReferenceTrackID = reader.ReadUInt32();
            this.NtpTimestamp     = reader.ReadUInt64();

            if (this.Version == 0)
            {
                this.MediaTime = reader.ReadUInt32();
            }
            else
            {
                this.MediaTime = reader.ReadUInt64();
            }
        }
コード例 #21
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 (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();
        }
コード例 #22
0
        /// <summary>
        /// Reads the descriptor properties from stream.
        /// </summary>
        /// <param name="reader">The binary reader with the stream.</param>
        protected override void ReadDescriptorPropertiesFromStream(BoxBinaryReader reader)
        {

            var initialOffset = reader.Offset;

            this.ObjectTypeIndication = (DecoderObjectTypes)reader.ReadByte();
            byte num = reader.ReadByte();
            this.StreamType = (byte)((num >> 2) & 0x3f);
            this.UpStream = (num & 2) != 0;
            this.BufferSize = reader.ReadUInt24();
            this.MaxBitrate = reader.ReadUInt32();
            this.AverageBitrate = reader.ReadUInt32();

            ReadSubDescriptors(reader, initialOffset);
        }
コード例 #23
0
        /// <summary>
        /// Reads the descriptor properties from stream.
        /// </summary>
        /// <param name="reader">The binary reader with the stream.</param>
        protected override void ReadDescriptorPropertiesFromStream(BoxBinaryReader reader)
        {
            var initialOffset = reader.Offset;

            this.ObjectTypeIndication = (DecoderObjectTypes)reader.ReadByte();
            byte num = reader.ReadByte();

            this.StreamType     = (byte)((num >> 2) & 0x3f);
            this.UpStream       = (num & 2) != 0;
            this.BufferSize     = reader.ReadUInt24();
            this.MaxBitrate     = reader.ReadUInt32();
            this.AverageBitrate = reader.ReadUInt32();

            ReadSubDescriptors(reader, initialOffset);
        }
コード例 #24
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.DefaultSampleInfoSize = reader.ReadByte();
            this.SampleCount           = reader.ReadUInt32();

            if (this.DefaultSampleInfoSize == 0)
            {
                this.SampleInfoSize = reader.ReadBytes(System.Convert.ToInt32(this.SampleCount));
            }
        }
        /// <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.DefaultSampleInfoSize = reader.ReadByte();
            this.SampleCount = reader.ReadUInt32();

            if (this.DefaultSampleInfoSize == 0)
            {
                this.SampleInfoSize = reader.ReadBytes(System.Convert.ToInt32(this.SampleCount));
            }
        }
コード例 #26
0
        /// <summary>
        /// Reads the box properties from stream.
        /// </summary>
        /// <param name="reader">The binary reader with the stream.</param>
        protected override void ReadBoxPropertiesFromStream(BoxBinaryReader reader)
        {
            uint versionAndFlags = reader.ReadUInt32();
            this.Version = (versionAndFlags >> 0x18) & 0xff;
            this.Flags = versionAndFlags & 0xffffff;

            ReadFullBoxPropertiesFromStream(reader);
        }
コード例 #27
0
 /// <summary>
 /// Reads the box properties from stream.
 /// </summary>
 /// <param name="reader">The binary reader with the stream.</param>
 protected override void ReadBoxPropertiesFromStream(BoxBinaryReader reader)
 {
     long num = this.Size - 8;
     while (num >= 4)
     {
         this.TrackIds.Add(reader.ReadUInt32());
         num -= 4;
     }
 }
コード例 #28
0
        /// <summary>
        /// Reads the box properties from stream.
        /// </summary>
        /// <param name="reader">The binary reader with the stream.</param>
        protected override void ReadBoxPropertiesFromStream(BoxBinaryReader reader)
        {
            uint versionAndFlags = reader.ReadUInt32();

            this.Version = (versionAndFlags >> 0x18) & 0xff;
            this.Flags   = versionAndFlags & 0xffffff;

            ReadFullBoxPropertiesFromStream(reader);
        }
コード例 #29
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);
        }
コード例 #30
0
 /// <summary>
 /// Reads the box properties from stream.
 /// </summary>
 /// <param name="reader">The binary reader with the stream.</param>
 /// <remarks>
 /// The CFF format makes the following changes.
 /// * MajorBrand will be set to "ccff"
 /// * MinorVersion will be set to 0x00000000
 /// * CompatibleBrands will have at least one additional brand encoded with "iso6"
 /// </remarks>
 protected override void ReadBoxPropertiesFromStream(BoxBinaryReader reader)
 {
     this.MajorBrand = reader.ReadString(4);
     this.MinorVersion = reader.ReadUInt32();
     
     while (reader.Offset < this.Offset + this.Size)
     {
         this.CompatibleBrands.Add(reader.ReadString(4));
     }
 }
コード例 #31
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);
        }
コード例 #32
0
        /// <summary>
        /// Reads the box properties from stream.
        /// </summary>
        /// <param name="reader">The binary reader with the stream.</param>
        /// <remarks>
        /// The CFF format makes the following changes.
        /// * MajorBrand will be set to "ccff"
        /// * MinorVersion will be set to 0x00000000
        /// * CompatibleBrands will have at least one additional brand encoded with "iso6"
        /// </remarks>
        protected override void ReadBoxPropertiesFromStream(BoxBinaryReader reader)
        {
            this.MajorBrand   = reader.ReadString(4);
            this.MinorVersion = reader.ReadUInt32();

            while (reader.Offset < this.Offset + this.Size)
            {
                this.CompatibleBrands.Add(reader.ReadString(4));
            }
        }
コード例 #33
0
        /// <summary>
        /// Reads the box properties from stream.
        /// </summary>
        /// <param name="reader">The binary reader with the stream.</param>
        protected override void ReadBoxPropertiesFromStream(BoxBinaryReader reader)
        {
            long num = this.Size - 8;

            while (num >= 4)
            {
                this.TrackIds.Add(reader.ReadUInt32());
                num -= 4;
            }
        }
コード例 #34
0
        /// <summary>
        /// Reads the box properties from stream.
        /// </summary>
        /// <param name="reader">The binary reader with the stream.</param>
        protected override void ReadBoxPropertiesFromStream(BoxBinaryReader reader)
        {
            var num = reader.ReadByte();

            this.Profile = (num >> 6);
            this.Level = (num & 0xF) >> 1;
            this.AdvancedProfileLevel = reader.ReadByte() >> 5;
            this.flags = reader.ReadByte(); //no_interlace, no_multiple_seq, no_multiple_entry, no_slice_code, no_bframe            
            this.Framerate = reader.ReadUInt32();
            this.CodecPrivateData = reader.ReadBytes((int)(this.Size - (reader.Offset - this.Offset)));
        }
コード例 #35
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)
        {
            this.SystemId = reader.ReadGuid();
            if (string.Compare(this.SystemId.ToString(), "9A04F079-9840-4286-AB92-E65BE0885F95", StringComparison.OrdinalIgnoreCase) != 0)
            {
                throw new BoxException(string.Format("The specified protection system id \"{0}\" is not supported", this.SystemId));
            }

            this.DataSize = reader.ReadUInt32();
            this.Data     = reader.ReadBytes(System.Convert.ToInt32(this.DataSize));
        }
        /// <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.SystemId = reader.ReadGuid();
            if (string.Compare(this.SystemId.ToString(), "9A04F079-9840-4286-AB92-E65BE0885F95", StringComparison.OrdinalIgnoreCase) != 0)
            {
                throw new BoxException(string.Format("The specified protection system id \"{0}\" is not supported", this.SystemId));
            }

            this.DataSize = reader.ReadUInt32();
            this.Data = reader.ReadBytes(System.Convert.ToInt32(this.DataSize));
        }
コード例 #37
0
        /// <summary>
        /// Reads the box properties from stream.
        /// </summary>
        /// <param name="reader">The binary reader with the stream.</param>
        protected override void ReadBoxPropertiesFromStream(BoxBinaryReader reader)
        {
            var num = reader.ReadByte();

            this.Profile = (num >> 6);
            this.Level   = (num & 0xF) >> 1;
            this.AdvancedProfileLevel = reader.ReadByte() >> 5;
            this.flags            = reader.ReadByte(); //no_interlace, no_multiple_seq, no_multiple_entry, no_slice_code, no_bframe
            this.Framerate        = reader.ReadUInt32();
            this.CodecPrivateData = reader.ReadBytes((int)(this.Size - (reader.Offset - this.Offset)));
        }
コード例 #38
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 (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();

        }
コード例 #39
0
        /// <summary>
        /// Reads the sample entry properties from stream.
        /// </summary>
        /// <param name="reader">The stream reader.</param>
        internal override void ReadSampleEntryPropertiesFromStream(BoxBinaryReader reader)
        {
            this.reserved1    = reader.ReadUInt16();
            this.reserved2    = reader.ReadUInt16();
            this.reserved3    = reader.ReadUInt32();
            this.ChannelCount = reader.ReadUInt16();
            this.SampleSize   = reader.ReadUInt16();
            this.predefined   = reader.ReadUInt16();
            this.reserved4    = reader.ReadUInt16();
            this.SampleRate   = reader.ReadUInt32();

            if (reader.PeekNextBoxType() != BoxType.Null)
            {
                ReadInnerBoxes(reader, BoxType.Esds, BoxType.Wfex, BoxType.Sinf, BoxType.Dec3, BoxType.Dac3, BoxType.Dmlp, BoxType.Ddts);
                this.AudioCodecData = GetAudioCodecDataFromInnerBoxes();
            }
            else
            {
                var waveFormatEx = new WaveFormatEx(reader);
                this.AudioCodecData = new AudioTrackCodecData(waveFormatEx);
            }
        }
コード例 #40
0
        /// <summary>
        /// Reads the sample entry properties from stream.
        /// </summary>
        /// <param name="reader">The stream reader.</param>
        internal override void ReadSampleEntryPropertiesFromStream(BoxBinaryReader reader)
        {
            this.reserved1 = reader.ReadUInt16();
            this.reserved2 = reader.ReadUInt16();
            this.reserved3 = reader.ReadUInt32();
            this.ChannelCount = reader.ReadUInt16();
            this.SampleSize = reader.ReadUInt16();
            this.predefined = reader.ReadUInt16();
            this.reserved4 = reader.ReadUInt16();
            this.SampleRate = reader.ReadUInt32();

            if (reader.PeekNextBoxType() != BoxType.Null)
            {
                ReadInnerBoxes(reader, BoxType.Esds, BoxType.Wfex, BoxType.Sinf, BoxType.Dec3, BoxType.Dac3, BoxType.Dmlp, BoxType.Ddts);
                this.AudioCodecData = GetAudioCodecDataFromInnerBoxes();
            }
            else
            {
                var waveFormatEx = new WaveFormatEx(reader);
                this.AudioCodecData = new AudioTrackCodecData(waveFormatEx);
            }
        }
コード例 #41
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();
                }
            }
        }
コード例 #42
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 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();
                }
            }
        }
コード例 #44
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)
 {
     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();
     }
 }
コード例 #45
0
        /// <summary>
        /// This method of building the mfra will make web requests in order to download the data
        /// from the online source.
        /// </summary>
        /// <param name="callback">The action that should be notified when the process is complete.</param>
        private async Task ReadMovieFragmentRandomAccess()
        {
#if !RANGESUFFIXSUPPORTED // not all backend services support range suffixes. For example, Azure Blobs. Here is a way around this but it requires an extra request to get the length and therefore does not perform as well.
            var fileSize = await WebRequestor.GetFileSizeAsync(this.fileUri);
#endif

            // grab the mfra offset
#if RANGESUFFIXSUPPORTED
            var offsetStream = await WebRequestor.GetStreamRangeAsync(this.fileUri, -4);
#else
            var offsetStream = await WebRequestor.GetStreamRangeNoSuffixAsync(this.fileUri, -4, fileSize);
#endif
            uint mfraOffset = 0;

            using (var reader = new BoxBinaryReader(offsetStream))
            {
                mfraOffset = reader.ReadUInt32();
            }

            // grab the mfra data
#if RANGESUFFIXSUPPORTED
            var mfraStream = await WebRequestor.GetStreamRangeAsync(this.fileUri, -mfraOffset);
#else
            var mfraStream = await WebRequestor.GetStreamRangeNoSuffixAsync(this.fileUri, -mfraOffset, fileSize);
#endif
            // Write the bytes to our TOC file
            using (var reader = new BoxBinaryReader(mfraStream))
            {
                reader.GotoPosition(0);

                Box box = null;

                do
                {
                    box = reader.ReadNextBox();
                    if (box != null)
                    {
                        this.Boxes.Add(box);
                    }
                } while (box != null);
            }
        }
コード例 #46
0
        private uint ReadIntValueFromBytes(BoxBinaryReader reader, byte numberOfBytes)
        {
            switch (numberOfBytes)
            {
            case 0:
                return(reader.ReadByte());

            case 1:
                return(reader.ReadUInt16());

            case 2:
                return(reader.ReadUInt24());

            case 3:
                return(reader.ReadUInt32());

            default:
                throw new BoxException("Specified number of bytes to parse an integer is not supported in the traf box.");
            }
        }
コード例 #47
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);
        }
コード例 #48
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);
        }
コード例 #49
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)
 {
     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();
     }
 }
コード例 #50
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)
        {
            this.SampleCount = reader.ReadUInt32();

            if ((this.Flags & 1) != 0)
            {
                this.DataOffset = (int)reader.ReadUInt32();
            }

            if ((this.Flags & 4) != 0)
            {
                this.FirstSampleFlags = reader.ReadUInt32();
            }


            for (int i = 0; i < this.SampleCount; i++)
            {
                var sample = new Sample();

                if ((base.Flags & 0x100) != 0)
                {
                    sample.SampleDuration = reader.ReadUInt32();
                }
                if ((base.Flags & 0x200) != 0)
                {
                    sample.SampleSize = reader.ReadUInt32();
                }
                if ((base.Flags & 0x400) != 0)
                {
                    sample.SampleFlags = reader.ReadUInt32();
                }
                if ((base.Flags & 0x800) != 0)
                {
                    sample.SampleCompositionTimeOffset = reader.ReadUInt32();
                }
            }
        }
コード例 #51
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)
        {
            this.SampleCount = reader.ReadUInt32();

            if ((this.Flags & 1) != 0)
            {
                this.DataOffset = (int)reader.ReadUInt32();
            }

            if ((this.Flags & 4) != 0)
            {
                this.FirstSampleFlags = reader.ReadUInt32();
            }

            
            for (int i = 0; i < this.SampleCount; i++)
            {
                var sample = new Sample();

                if ((base.Flags & 0x100) != 0)
                {
                    sample.SampleDuration = reader.ReadUInt32();
                }
                if ((base.Flags & 0x200) != 0)
                {
                    sample.SampleSize = reader.ReadUInt32();
                }
                if ((base.Flags & 0x400) != 0)
                {
                    sample.SampleFlags = reader.ReadUInt32();
                }
                if ((base.Flags & 0x800) != 0)
                {
                    sample.SampleCompositionTimeOffset = reader.ReadUInt32();
                }
            }
        }
コード例 #52
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)
        {
            this.EntryCount = reader.ReadUInt32();

            ReadInnerBoxes(reader, BoxType.Enca, BoxType.Encs, BoxType.Enct, BoxType.Encv, BoxType.Vide, BoxType.Soun, BoxType.Esds, BoxType.Subt);
        }
 private uint ReadIntValueFromBytes(BoxBinaryReader reader, byte numberOfBytes)
 {
     switch (numberOfBytes)
     {
         case 0:
             return reader.ReadByte();
         case 1:
             return reader.ReadUInt16();
         case 2:
             return reader.ReadUInt24();
         case 3:
             return reader.ReadUInt32();
         default:
             throw new BoxException("Specified number of bytes to parse an integer is not supported in the traf box.");
     }
 }
コード例 #54
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)
 {
     this.SequenceNumber = reader.ReadUInt32();
 }
コード例 #55
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)
 {
     this.MfraReverseOffset = reader.ReadUInt32();
 }
コード例 #57
0
        /// <summary>
        /// Reads the sample entry properties from stream.
        /// </summary>
        /// <param name="reader">The stream reader.</param>
        internal override void ReadSampleEntryPropertiesFromStream(BoxBinaryReader reader)
        {
            predefined1 = reader.ReadUInt16();
            reserved1 = reader.ReadUInt16();
            predefined2 = reader.ReadBytes(12);
            this.Width = reader.ReadUInt16();
            this.Height = reader.ReadUInt16();
            this.HorizResolution = reader.ReadUInt32();
            this.VertResolution = reader.ReadUInt32();
            reserved2 = reader.ReadUInt32();
            this.FrameCount = reader.ReadUInt16();

            byte[] buffer = new byte[0x20];
            reader.Read(buffer, 0, 0x20);
            int count = buffer[0];
            if (count < 0x20)
            {
                this.CompressorName = Encoding.UTF8.GetString(buffer, 1, count);
            }
            this.Depth = reader.ReadUInt16();
            predefined3 = reader.ReadUInt16();

            if (reader.PeekNextBoxType() != BoxType.Null)
            {
                ReadInnerBoxes(reader, BoxType.Esds, BoxType.Avcc, BoxType.Avc1, BoxType.Dvc1, BoxType.Btrt, BoxType.Sinf);
                this.VideoCodecData = GetVideoCodecDataFromInnerBoxes();
            }
            else
            {
                var videoInfoHeader = new VideoInfoHeader2(reader);
                this.VideoCodecData = new VideoTrackCodecData(videoInfoHeader);
            }

        }
コード例 #58
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)
        {
            this.EntryCount = reader.ReadUInt32();

            ReadInnerBoxes(reader, BoxType.Enca, BoxType.Encs, BoxType.Enct, BoxType.Encv, BoxType.Vide, BoxType.Soun, BoxType.Esds, BoxType.Subt);
        }
コード例 #59
0
 /// <summary>
 /// Reads the box properties from stream.
 /// </summary>
 /// <param name="reader">The binary reader with the stream.</param>
 protected override void ReadBoxPropertiesFromStream(BoxBinaryReader reader)
 {
     BufferSizeDB = reader.ReadUInt32();
     MaxBitRate = reader.ReadUInt32();
     AvgBitRate = reader.ReadUInt32();
 }
コード例 #60
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)
 {
     this.SequenceNumber = reader.ReadUInt32();
 }