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 void ReadChildren(Mp4Stream stream, Mp4BoxFactory factory, long size) { this.Children = new List <Mp4Box>(); Mp4Box item = null; long bytesAvailable = size; factory.PushContext(base.Type); while ((bytesAvailable > 0L) && ((item = factory.Read(stream, ref bytesAvailable)) != null)) { item.Parent = this; this.Children.Add(item); } factory.PopContext(); }
public Mp4DrefBox(uint size, Mp4Stream stream, Mp4BoxFactory factory) : base(size, Mp4BoxType.DREF, 0L, stream) { uint num = stream.ReadUInt32(); this.Entries = new List <Mp4Box>((int)num); uint num2 = num; long bytesAvailable = (size - 12) - 4; while (num2-- > 0) { Mp4Box item = null; while ((item = factory.Read(stream, ref bytesAvailable)) != null) { this.Entries.Add(item); } } }
public Mp4StsdBox(uint size, Mp4Stream stream, Mp4BoxFactory factory) : base(size, Mp4BoxType.STSD, 0L, stream) { uint num = stream.ReadUInt32(); factory.PushContext(base.Type); long bytesAvailable = (size - 12) - 4; this.Entries = new List <Mp4Box>((int)num); for (int i = 0; i < num; i++) { Mp4Box item = factory.Read(stream, ref bytesAvailable); if (item != null) { this.Entries.Add(item); } } factory.PopContext(); }
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 void AddChild(Mp4Box child, int position) { if (child.Parent != null) { throw new Mp4Exception("Child already have a parent"); } if (position == -1) { this.Children.Add(child); } else { this.Children.Insert(position, child); } child.Parent = this; if (this.Size != 1) { this.Size += (child.Size != 1) ? child.Size : ((uint)child.LargeSize); } else { this.LargeSize += (child.Size != 1) ? ((ulong)child.Size) : ((ulong)((uint)child.LargeSize)); } }
public void AddChild(Mp4Box child) { this.AddChild(child, -1); }