public Mp4TkhdBox(DateTime creationTime, DateTime modificationTime, uint trackId, ulong duration, ushort volume, uint width, uint height) : base(0x68, Mp4BoxType.TKHD, 0L, 1, 7) { this.Reserved2 = new byte[8]; this.Matrix = new uint[9]; this.CreationTime = Mp4Util.ConvertTime(creationTime); this.ModificationTime = Mp4Util.ConvertTime(modificationTime); this.TrackId = trackId; this.Reserved1 = 0; this.Duration = duration; this.Layer = 0; this.AlternateGroup = 0; this.Volume = volume; this.Reserved3 = 0; this.Width = width; this.Height = height; this.Matrix[0] = 0x10000; this.Matrix[1] = 0; this.Matrix[2] = 0; this.Matrix[3] = 0; this.Matrix[4] = 0x10000; this.Matrix[5] = 0; this.Matrix[6] = 0; this.Matrix[7] = 0; this.Matrix[8] = 0x40000000; this.Reserved2[0] = 0; this.Reserved2[1] = 0; }
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 Mp4MdhdBox(DateTime creationTime, DateTime modificationTime, uint timeScale, ulong duration, string language) : base(0x2c, Mp4BoxType.MDHD, 0L, 1, 0) { this.CreationTime = Mp4Util.ConvertTime(creationTime); this.ModificationTime = Mp4Util.ConvertTime(modificationTime); this.TimeScale = timeScale; this.Duration = duration; this.Language = language; if (language.Length != 3) { throw new Mp4Exception("Language must be of length 3."); } }
public Mp4StcoBox(uint size, Mp4Stream stream) : base(size, Mp4BoxType.STCO, 0L, stream) { uint num = stream.ReadUInt32(); if (num > (((size - 12) - 4) / 4)) { num = ((size - 12) - 4) / 4; } this.Entries = new List <uint>((int)num); byte[] buffer = new byte[num * 4]; stream.Read(buffer, (int)(num * 4)); for (int i = 0; i < num; i++) { this.Entries.Add(Mp4Util.BytesToUInt32BE(buffer, i * 4)); } }
public Mp4StszBox(uint size, Mp4Stream stream) : base(size, Mp4BoxType.STSZ, 0L, stream) { this.SampleSize = stream.ReadUInt32(); uint num = stream.ReadUInt32(); if (this.SampleSize == 0) { this.Entries = new List <uint>((int)num); byte[] buffer = new byte[num * 4]; stream.Read(buffer, (int)(num * 4)); for (uint i = 0; i < num; i++) { this.Entries.Add(Mp4Util.BytesToUInt32BE(buffer, (int)(i * 4))); } } else { this.Entries = new List <uint>(); } }
public static T FindChild <T>(this IMp4ContainerBox container, string path) where T : Mp4Box { IMp4ContainerBox box = container; while (path.Length >= 4) { string str; if (path.Length == 4) { str = null; } else if (path[4] == '/') { str = path.Substring(5); } else { return(default(T)); } uint type = Mp4Util.Create(path[0], path[1], path[2], path[3]); Mp4Box child = box.GetChild <Mp4Box>(type); if (child == null) { return(default(T)); } if (str != null) { path = str; box = child as IMp4ContainerBox; if (box == null) { return(default(T)); } } else { return((T)child); } } return(default(T)); }
public Mp4MvhdBox(DateTime creationTime, DateTime modificationTime, uint timeScale, ulong duration, uint rate, ushort volume) : base(120, Mp4BoxType.MVHD, 0L, 1, 0) { this.Reserved1 = new byte[2]; this.Reserved2 = new byte[8]; this.Matrix = new uint[9]; this.Predefined = new byte[0x18]; this.CreationTime = Mp4Util.ConvertTime(creationTime); this.ModificationTime = Mp4Util.ConvertTime(modificationTime); this.TimeScale = timeScale; this.Duration = duration; this.Rate = rate; this.Volume = volume; this.NextTrackId = uint.MaxValue; this.Matrix[0] = 0x10000; this.Matrix[1] = 0; this.Matrix[2] = 0; this.Matrix[3] = 0; this.Matrix[4] = 0x10000; this.Matrix[5] = 0; this.Matrix[6] = 0; this.Matrix[7] = 0; this.Matrix[8] = 0x40000000; }
public Mp4CttsBox(uint size, Mp4Stream stream) : base(size, Mp4BoxType.CTTS, 0L, stream) { this.lookupCache = new LookupCache(); uint num = stream.ReadUInt32(); this.Entries = new List <Mp4CttsEntry>((int)num); byte[] buffer = new byte[num * 8]; stream.Read(buffer, (int)(num * 8)); bool flag = false; int num2 = 0; for (int i = 0; i < num; i++) { this.Entries.Add(new Mp4CttsEntry()); this.Entries[i].SampleCount = Mp4Util.BytesToUInt32BE(buffer, i * 8); uint num4 = Mp4Util.BytesToUInt32BE(buffer, (i * 8) + 4); if ((num4 & 0x80000000) != 0) { flag = true; int num5 = (int)num4; if (num5 < num2) { num2 = num5; } } this.Entries[i].SampleOffset = num4; } if (flag) { for (int j = 0; j < num; j++) { Mp4CttsEntry local1 = this.Entries[j]; local1.SampleOffset -= (uint)num2; } } }
public uint ReadUInt32() { byte[] buffer = new byte[4]; this.Read(buffer, 4); return(Mp4Util.BytesToUInt32BE(buffer)); }
public long ReadInt64() { byte[] buffer = new byte[8]; this.Read(buffer, 8); return((long)Mp4Util.BytesToUInt64BE(buffer)); }
public double ReadDouble() { byte[] buffer = new byte[8]; this.Read(buffer, 8); return(Mp4Util.BytesToDoubleBE(buffer)); }
public void WriteUInt64(ulong value) { byte[] bytes = new byte[8]; Mp4Util.BytesFromUInt64BE(bytes, value); this.Write(bytes, 8); }
public void WriteUInt32(uint value) { byte[] bytes = new byte[4]; Mp4Util.BytesFromUInt32BE(bytes, value); this.Write(bytes, 4); }
public void WriteUInt24(uint value) { byte[] bytes = new byte[3]; Mp4Util.BytesFromUInt24BE(bytes, value); this.Write(bytes, 3); }
public void WriteUInt16(ushort value) { byte[] bytes = new byte[2]; Mp4Util.BytesFromUInt16BE(bytes, value); this.Write(bytes, 2); }
public void WriteDouble(double value) { byte[] bytes = new byte[8]; Mp4Util.BytesFromDoubleBE(bytes, value); this.Write(bytes, 8); }
public override string ToString() => (Mp4Util.FormatFourChars(this.Type) + "(" + ((this.Size != 1) ? ("Size:" + this.Size) : ("LargeSize" + this.LargeSize)) + ((this.Parent != null) ? (",Parent:" + Mp4Util.FormatFourChars(this.Parent.Type)) : "") + ")");
public ushort ReadUInt16() { byte[] buffer = new byte[2]; this.Read(buffer, 2); return(Mp4Util.BytesToUInt16BE(buffer)); }
public uint ReadUInt24() { byte[] buffer = new byte[3]; this.Read(buffer, 3); return(Mp4Util.BytesToUInt24BE(buffer)); }
public override string ToString() { object obj2 = string.Empty; return(string.Concat(new object[] { obj2, "ftyp(MajorBrand:", Mp4Util.FormatFourChars(this.MajorBrand), ",MinorVersion:", this.MinorVersion }) + ((this.CompatibleBrands.Count > 0) ? (",CompatibleBrands:" + Mp4Util.FormatFourChars(this.CompatibleBrands)) : "") + ")"); }