public override void WriteFields(Mp4Stream stream) { stream.WriteUInt16(this.EsId); byte num = (byte)(this.StreamPriority | ((byte)(this.Flags << 5))); stream.WriteUInt08(num); if ((this.Flags & 1) != 0) { stream.WriteUInt16(this.DependsOn); } if ((this.Flags & 2) != 0) { byte[] bytes = Encoding.ASCII.GetBytes(this.Url); stream.WriteUInt08((byte)bytes.Length); stream.Write(bytes, bytes.Length); stream.WriteUInt08(0); } if ((this.Flags & 4) != 0) { stream.WriteUInt16(this.OcrEsId); } foreach (Mp4Descriptor descriptor in this.SubDescriptors) { descriptor.Write(stream); } }
public Mp4RtpHintSampleEntry(uint size, Mp4Stream stream, Mp4BoxFactory factory) : base(size, Mp4BoxType.RTP_) { uint fieldsSize = this.GetFieldsSize(); this.ReadFields(stream); base.ReadChildren(stream, factory, (long)((size - 8) - fieldsSize)); }
public Mp4ElstBox(uint size, Mp4Stream stream) : base(size, Mp4BoxType.ELST, 0L, stream) { uint num = stream.ReadUInt32(); this.Entries = new List <Mp4ElstEntry>(); for (uint i = 0; i < num; i++) { short num3; if (base.Version == 0) { uint num4 = stream.ReadUInt32(); int num5 = stream.ReadInt32(); num3 = stream.ReadInt16(); stream.ReadInt16(); this.Entries.Add(new Mp4ElstEntry((ulong)num4, (long)num5, num3)); } else { ulong segmentDuration = stream.ReadUInt64(); long mediaTime = stream.ReadInt64(); num3 = stream.ReadInt16(); stream.ReadInt16(); this.Entries.Add(new Mp4ElstEntry(segmentDuration, mediaTime, num3)); } } }
public Mp4MdhdBox(uint size, Mp4Stream stream) : base(size, Mp4BoxType.MDHD, 0L, stream) { if (base.Version == 0) { this.CreationTime = stream.ReadUInt32(); this.ModificationTime = stream.ReadUInt32(); this.TimeScale = stream.ReadUInt32(); this.Duration = stream.ReadUInt32(); } else { this.CreationTime = stream.ReadUInt64(); this.ModificationTime = stream.ReadUInt64(); this.TimeScale = stream.ReadUInt32(); this.Duration = stream.ReadUInt64(); } byte[] buffer = new byte[2]; stream.Read(buffer, 2); byte num = (byte)(((byte)(buffer[0] >> 2)) & 0x1f); byte num2 = (byte)((((byte)(buffer[0] & 3)) << 3) | ((buffer[1] >> 5) & 7)); byte num3 = (byte)(buffer[1] & 0x1f); if (((num != 0) && (num2 != 0)) && (num3 != 0)) { char[] chArray = new char[] { (char)(num + 0x60), (char)(num2 + 0x60), (char)(num3 + 0x60) }; this.Language = new string(chArray); } else { this.Language = "```"; } }
public override void ReadFields(Mp4Stream stream) { base.ReadFields(stream); this.HintTrackVersion = stream.ReadUInt16(); this.HighestCompatibleVersion = stream.ReadUInt16(); this.MaxPacketSize = stream.ReadUInt32(); }
public override void WriteBody(Mp4Stream stream) { stream.WriteUInt32((uint)this.Entries.Count); if ((base.Flags & 1) != 0) { stream.WriteUInt32((uint)this.DataOffset); } if ((base.Flags & 4) != 0) { stream.WriteUInt32(this.FirstSampleFlags); } for (int i = 0; i < this.Entries.Count; i++) { if ((base.Flags & 0x100) != 0) { stream.WriteUInt32(this.Entries[i].SampleDuration); } if ((base.Flags & 0x200) != 0) { stream.WriteUInt32(this.Entries[i].SampleSize); } if ((base.Flags & 0x400) != 0) { stream.WriteUInt32(this.Entries[i].SampleFlags); } if ((base.Flags & 0x800) != 0) { stream.WriteUInt32(this.Entries[i].SampleCompositionTimeOffset); } } }
public Mp4AudioSampleEntry(uint size, uint format, Mp4Stream stream, Mp4BoxFactory factory) : base(size, format) { this.ReadFields(stream); uint fieldsSize = this.GetFieldsSize(); base.ReadChildren(stream, factory, (long)((size - 8) - fieldsSize)); }
public Mp4File(Mp4Stream stream, Mp4BoxFactory factory, bool moovOnly) { this.Boxes = new List <Mp4Box>(); bool flag = true; while (flag) { long position = stream.Position; Mp4Box item = factory.Read(stream); if (item != null) { this.Boxes.Add(item); if (item.Type == Mp4BoxType.MOOV) { this.Movie = new Mp4Movie((Mp4MoovBox)item, stream); if (moovOnly) { flag = false; } } else if (item.Type == Mp4BoxType.FTYP) { this.FileType = (Mp4FtypBox)item; } else if ((item.Type == Mp4BoxType.MDAT) && (this.Movie == null)) { this.MoovIsBeforeMdat = false; } } else { flag = false; } } }
public Mp4TkhdBox(uint size, Mp4Stream stream) : base(size, Mp4BoxType.TKHD, 0L, stream) { this.Reserved2 = new byte[8]; this.Matrix = new uint[9]; if (base.Version == 0) { this.CreationTime = stream.ReadUInt32(); this.ModificationTime = stream.ReadUInt32(); this.TrackId = stream.ReadUInt32(); this.Reserved1 = stream.ReadUInt32(); this.Duration = stream.ReadUInt32(); } else { this.CreationTime = stream.ReadUInt64(); this.ModificationTime = stream.ReadUInt64(); this.TrackId = stream.ReadUInt32(); this.Reserved1 = stream.ReadUInt32(); this.Duration = stream.ReadUInt64(); } stream.Read(this.Reserved2, 8); this.Layer = stream.ReadUInt16(); this.AlternateGroup = stream.ReadUInt16(); this.Volume = stream.ReadUInt16(); this.Reserved3 = stream.ReadUInt16(); for (int i = 0; i < 9; i++) { this.Matrix[i] = stream.ReadUInt32(); } this.Width = stream.ReadUInt32(); this.Height = stream.ReadUInt32(); }
public Mp4StscBox(uint size, Mp4Stream stream) : base(size, Mp4BoxType.STSC, 0L, stream) { uint num = 1; uint num2 = stream.ReadUInt32(); this.Entries = new List <Mp4StscEntry>((int)num2); byte[] buffer = new byte[num2 * 12]; stream.Read(buffer, (int)(num2 * 12)); for (int i = 0; i < num2; i++) { uint num4 = Mp4Util.BytesToUInt32BE(buffer, i * 12); uint num5 = Mp4Util.BytesToUInt32BE(buffer, (i * 12) + 4); uint num6 = Mp4Util.BytesToUInt32BE(buffer, (i * 12) + 8); if (i > 0) { int num7 = i - 1; this.Entries[num7].ChunkCount = num4 - this.Entries[num7].FirstChunk; num += this.Entries[num7].ChunkCount * this.Entries[num7].SamplesPerChunk; } this.Entries.Add(new Mp4StscEntry()); this.Entries[i].ChunkCount = 0; this.Entries[i].FirstChunk = num4; this.Entries[i].FirstSample = num; this.Entries[i].SamplesPerChunk = num5; this.Entries[i].SampleDescriptionIndex = num6; } }
public virtual void AddSample(Mp4Stream dataStream, ulong offset, uint size, uint duration, uint descriptionIndex, ulong dts, uint ctsDelta, bool sync) { if (this.samples.Count > 0) { Mp4Sample sample = this.samples[this.samples.Count - 1]; if (dts == 0L) { if (sample.Duration == 0) { throw new Exception("INVALID_PARAMETERS"); } dts = sample.Dts + sample.Duration; } else if (sample.Duration == 0) { if (dts <= sample.Dts) { throw new Exception("INVALID_PARAMETERS"); } sample.Duration = (uint)(dts - sample.Dts); } else if (dts != (sample.Dts + sample.Duration)) { throw new Exception("INVALID_PARAMETERS"); } } Mp4Sample item = new Mp4Sample(dataStream, (long)offset, (int)size, duration, descriptionIndex, dts, ctsDelta, sync); this.samples.Add(item); }
public override void WriteFields(Mp4Stream stream) { if ((base.PayloadSize != 0) && (this.Info != null)) { stream.Write(this.Info, this.Info.Length); } }
public Mp4HdlrBox(uint size, Mp4Stream stream) : base(size, Mp4BoxType.HDLR, 0L, stream) { this.Reserved = new uint[3]; this.PreDefined = stream.ReadUInt32(); this.HandlerType = stream.ReadUInt32(); this.Reserved[0] = stream.ReadUInt32(); this.Reserved[1] = stream.ReadUInt32(); this.Reserved[2] = stream.ReadUInt32(); int count = ((int)size) - 0x1c; if (count > 0) { byte[] buffer = new byte[count]; stream.Read(buffer, count); if (buffer[0] == (count - 1)) { this.Name = Encoding.UTF8.GetString(buffer, 1, buffer.Length - 1); } else { this.Name = Encoding.UTF8.GetString(buffer); int index = this.Name.IndexOf('\0'); if (index != -1) { this.Name = this.Name.Substring(0, index); } } } else { this.Name = string.Empty; } }
public override void WriteBody(Mp4Stream stream) { for (int i = 0; i < this.TrackIds.Count; i++) { stream.WriteUInt32(this.TrackIds[i]); } }
public Mp4ObjectDescriptor(Mp4Stream stream, Mp4DescriptorTag tag, uint headerSize, uint payloadSize) : base(tag, headerSize, payloadSize) { Mp4Descriptor descriptor; long position = stream.Position; ushort num2 = stream.ReadUInt16(); this.ObjectDescriptorId = (ushort)(num2 >> 6); this.UrlFlag = (num2 & 0x20) != 0; if (this.UrlFlag) { byte count = stream.ReadUInt08(); byte[] buffer = new byte[0x100]; stream.Read(buffer, count); buffer[count] = 0; this.Url = Encoding.ASCII.GetString(buffer, 0, count); } long offset = stream.Position; this.SubDescriptors = new List <Mp4Descriptor>(); Mp4DescriptorFactory factory = new Mp4DescriptorFactory(); Mp4SubStream stream2 = new Mp4SubStream(stream, offset, (long)(payloadSize - ((uint)(offset - position)))); while ((descriptor = factory.Read(stream2)) != null) { this.SubDescriptors.Add(descriptor); } }
public override void WriteBody(Mp4Stream stream) { if (base.Version == 0) { stream.WriteUInt32((uint)this.CreationTime); stream.WriteUInt32((uint)this.ModificationTime); stream.WriteUInt32(this.TrackId); stream.WriteUInt32(this.Reserved1); stream.WriteUInt32((uint)this.Duration); } else { stream.WriteUInt64(this.CreationTime); stream.WriteUInt64(this.ModificationTime); stream.WriteUInt32(this.TrackId); stream.WriteUInt32(this.Reserved1); stream.WriteUInt64(this.Duration); } stream.Write(this.Reserved2, this.Reserved2.Length); stream.WriteUInt16(this.Layer); stream.WriteUInt16(this.AlternateGroup); stream.WriteUInt16(this.Volume); stream.WriteUInt16(this.Reserved3); for (int i = 0; i < 9; i++) { stream.WriteUInt32(this.Matrix[i]); } stream.WriteUInt32(this.Width); stream.WriteUInt32(this.Height); }
public Mp4TrunBox(uint size, Mp4Stream stream) : base(size, Mp4BoxType.TRUN, 0L, stream) { uint num = stream.ReadUInt32(); if ((base.Flags & 1) != 0) { this.DataOffset = (int)stream.ReadUInt32(); } if ((base.Flags & 4) != 0) { this.FirstSampleFlags = stream.ReadUInt32(); } this.Entries = new List <Mp4TrunEntry>((int)num); for (int i = 0; i < num; i++) { this.Entries.Add(new Mp4TrunEntry()); if ((base.Flags & 0x100) != 0) { this.Entries[i].SampleDuration = stream.ReadUInt32(); } if ((base.Flags & 0x200) != 0) { this.Entries[i].SampleSize = stream.ReadUInt32(); } if ((base.Flags & 0x400) != 0) { this.Entries[i].SampleFlags = stream.ReadUInt32(); } if ((base.Flags & 0x800) != 0) { this.Entries[i].SampleCompositionTimeOffset = stream.ReadUInt32(); } } }
public Mp4MvhdBox(uint size, Mp4Stream stream) : base(size, Mp4BoxType.MVHD, 0L, stream) { this.Reserved1 = new byte[2]; this.Reserved2 = new byte[8]; this.Matrix = new uint[9]; this.Predefined = new byte[0x18]; if (base.Version == 0) { this.CreationTime = stream.ReadUInt32(); this.ModificationTime = stream.ReadUInt32(); this.TimeScale = stream.ReadUInt32(); this.Duration = stream.ReadUInt32(); } else { this.CreationTime = stream.ReadUInt64(); this.ModificationTime = stream.ReadUInt64(); this.TimeScale = stream.ReadUInt32(); this.Duration = stream.ReadUInt64(); } this.Rate = stream.ReadUInt32(); this.Volume = stream.ReadUInt16(); stream.Read(this.Reserved1, this.Reserved1.Length); stream.Read(this.Reserved2, this.Reserved2.Length); for (int i = 0; i < 9; i++) { this.Matrix[i] = stream.ReadUInt32(); } stream.Read(this.Predefined, this.Predefined.Length); this.NextTrackId = stream.ReadUInt32(); }
public Mp4FullBox(uint size, uint type, ulong largeSize, Mp4Stream stream) : base(size, type, largeSize) { uint num = stream.ReadUInt32(); this.Version = (num >> 0x18) & 0xff; this.Flags = num & 0xffffff; }
public override void WriteBody(Mp4Stream stream) { if (base.Version == 0) { stream.WriteUInt32((uint)this.CreationTime); stream.WriteUInt32((uint)this.ModificationTime); stream.WriteUInt32(this.TimeScale); stream.WriteUInt32((uint)this.Duration); } else { stream.WriteUInt64(this.CreationTime); stream.WriteUInt64(this.ModificationTime); stream.WriteUInt32(this.TimeScale); stream.WriteUInt64(this.Duration); } stream.WriteUInt32(this.Rate); stream.WriteUInt16(this.Volume); stream.Write(this.Reserved1, this.Reserved1.Length); stream.Write(this.Reserved2, this.Reserved2.Length); for (int i = 0; i < 9; i++) { stream.WriteUInt32(this.Matrix[i]); } stream.Write(this.Predefined, this.Predefined.Length); stream.WriteUInt32(this.NextTrackId); }
public override void WriteInnerBody(Mp4Stream stream) { base.WriteInnerBody(stream); stream.WriteUInt16(this.QtVersion); stream.WriteUInt16(this.QtRevision); stream.WriteUInt32(this.QtVendor); stream.WriteUInt16(this.ChannelCount); stream.WriteUInt16(this.SampleSize); stream.WriteUInt16(this.QtCompressionId); stream.WriteUInt16(this.QtPacketSize); stream.WriteUInt32(this.SampleRate); if (this.QtVersion == 1) { stream.WriteUInt32(this.QtV1SamplesPerPacket); stream.WriteUInt32(this.QtV1BytesPerPacket); stream.WriteUInt32(this.QtV1BytesPerFrame); stream.WriteUInt32(this.QtV1BytesPerSample); } else if (this.QtVersion == 2) { stream.WriteUInt32(this.QtV2StructSize); stream.WriteDouble(this.QtV2SampleRate64); stream.WriteUInt32(this.QtV2ChannelCount); stream.WriteUInt32(this.QtV2Reserved); stream.WriteUInt32(this.QtV2BitsPerChannel); stream.WriteUInt32(this.QtV2FormatSpecificFlags); stream.WriteUInt32(this.QtV2BytesPerAudioPacket); stream.WriteUInt32(this.QtV2LPCMFramesPerAudioPacket); if (this.QtV2Extension != null) { stream.Write(this.QtV2Extension, this.QtV2Extension.Length); } } }
public Mp4UuidBox(uint size, Mp4Stream stream) : base(size, Mp4BoxType.UUID) { this.Uuid = new byte[0x10]; stream.Read(this.Uuid, 0x10); this.Stream = stream; this.Position = stream.Position; }
public Mp48bdlBox(uint size, Mp4Stream stream) : base(size, Mp4BoxType.LDB8) { this.Encoding = stream.ReadUInt32(); this.EncodingVersion = stream.ReadUInt32(); this.BundleData = new byte[(size - 8) - 8]; stream.Read(this.BundleData, this.BundleData.Length); }
public override void WriteInnerBody(Mp4Stream stream) { base.WriteInnerBody(stream); stream.WriteUInt16(this.Predefined1); stream.WriteUInt16(this.Reserved2); stream.Write(this.Predefined2, this.Predefined2.Length); stream.WriteUInt16(this.Width); stream.WriteUInt16(this.Height); stream.WriteUInt32(this.HorizResolution); stream.WriteUInt32(this.VertResolution); stream.WriteUInt32(this.Reserved3); stream.WriteUInt16(this.FrameCount); byte[] buffer = new byte[0x20]; int length = this.CompressorName.Length; if (length > 0x1f) { length = 0x1f; } buffer[0] = (byte)length; for (int i = 0; i < length; i++) { buffer[i + 1] = (byte)this.CompressorName[i]; } for (int j = length + 1; j < 0x20; j++) { buffer[j] = 0; } stream.Write(buffer, 0x20); stream.WriteUInt16(this.Depth); stream.WriteUInt16(this.Predefined3); }
public override void WriteInnerBody(Mp4Stream stream) { base.WriteInnerBody(stream); stream.WriteUInt16(this.HintTrackVersion); stream.WriteUInt16(this.HighestCompatibleVersion); stream.WriteUInt32(this.MaxPacketSize); }
public override void WriteBody(Mp4Stream stream) { if (this.EsDescriptor != null) { this.EsDescriptor.Write(stream); } }
public override void WriteBody(Mp4Stream stream) { stream.WriteUInt08(this.ConfigurationVersion); stream.WriteUInt08(this.AVCProfileIndication); stream.WriteUInt08(this.AVCCompatibleProfiles); stream.WriteUInt08(this.AVCLevelIndication); byte num = 0xfc; if ((this.NaluLengthSize >= 1) && (this.NaluLengthSize <= 4)) { num = (byte)(num | ((byte)(this.NaluLengthSize - 1))); } stream.WriteUInt08(num); this.NaluLengthSize = (byte)(1 + (num & 3)); byte num2 = (byte)(this.SequenceParameters.Count & 0x31); stream.WriteUInt08((byte)(0xe0 | num2)); for (int i = 0; i < num2; i++) { ushort length = (ushort)this.SequenceParameters[i].Length; stream.WriteUInt16(length); stream.Write(this.SequenceParameters[i], length); } byte count = (byte)this.PictureParameters.Count; stream.WriteUInt08(count); for (int j = 0; j < count; j++) { ushort length = (ushort)this.PictureParameters[j].Length; stream.WriteUInt16(length); stream.Write(this.PictureParameters[j], length); } }
public Mp4AvccBox(uint size, Mp4Stream stream) : base(size, Mp4BoxType.AVCC) { long position = stream.Position; this.RawBytes = new byte[size]; stream.Read(this.RawBytes, this.RawBytes.Length); stream.Seek(position); this.ConfigurationVersion = stream.ReadUInt08(); this.AVCProfileIndication = stream.ReadUInt08(); this.AVCCompatibleProfiles = stream.ReadUInt08(); this.AVCLevelIndication = stream.ReadUInt08(); byte num2 = stream.ReadUInt08(); this.NaluLengthSize = (byte)(1 + (num2 & 3)); byte capacity = (byte)(stream.ReadUInt08() & 0x1f); this.SequenceParameters = new List <byte[]>(capacity); for (uint i = 0; i < capacity; i++) { byte[] buffer = new byte[stream.ReadUInt16()]; stream.Read(buffer, buffer.Length); this.SequenceParameters.Add(buffer); } byte num6 = stream.ReadUInt08(); this.PictureParameters = new List <byte[]>(); for (uint j = 0; j < num6; j++) { byte[] buffer = new byte[stream.ReadUInt16()]; stream.Read(buffer, buffer.Length); this.PictureParameters.Add(buffer); } }
public override void WriteBody(Mp4Stream stream) { stream.WriteUInt16(this.GraphicsMode); stream.WriteUInt16(this.OpColor[0]); stream.WriteUInt16(this.OpColor[1]); stream.WriteUInt16(this.OpColor[2]); }
public Mp4HmhdBox(uint size, Mp4Stream stream) : base(size, Mp4BoxType.HMHD, 0L, stream) { this.MaxPduSize = stream.ReadUInt16(); this.AvgPduSize = stream.ReadUInt16(); this.MaxBitrate = stream.ReadUInt32(); this.AvgBitrate = stream.ReadUInt32(); this.Reserved = stream.ReadUInt32(); }