/// <summary> /// Parses boxes for a specified range, looking for tags and /// properties. /// </summary> /// <param name="start"> /// A <see cref="long" /> value specifying the seek position /// at which to start reading. /// </param> /// <param name="end"> /// A <see cref="long" /> value specifying the seek position /// at which to stop reading. /// </param> /// <param name="handler"> /// A <see cref="IsoHandlerBox" /> object that applied to the /// range being searched. /// </param> private void ParseTagAndProperties(long start, long end, IsoHandlerBox handler) { BoxHeader header; for (long position = start; position < end; position += header.TotalBoxSize) { header = new BoxHeader(file, position); ByteVector type = header.BoxType; if (type == BoxType.Moov || type == BoxType.Mdia || type == BoxType.Minf || type == BoxType.Stbl || type == BoxType.Trak) { ParseTagAndProperties( header.HeaderSize + position, header.TotalBoxSize + position, handler); } else if (type == BoxType.Stsd) { stsd_boxes.Add(BoxFactory.CreateBox( file, header, handler)); } else if (type == BoxType.Hdlr) { handler = BoxFactory.CreateBox(file, header, handler) as IsoHandlerBox; } else if (mvhd_box == null && type == BoxType.Mvhd) { mvhd_box = BoxFactory.CreateBox(file, header, handler) as IsoMovieHeaderBox; } else if (udta_box == null && type == BoxType.Udta) { udta_box = BoxFactory.CreateBox(file, header, handler) as IsoUserDataBox; } else if (type == BoxType.Mdat) { mdat_start = position; mdat_end = position + header.TotalBoxSize; } if (header.TotalBoxSize == 0) { break; } } }
/// <summary> /// Parses boxes for a specified range, looking for chunk /// offset boxes. /// </summary> /// <param name="start"> /// A <see cref="long" /> value specifying the seek position /// at which to start reading. /// </param> /// <param name="end"> /// A <see cref="long" /> value specifying the seek position /// at which to stop reading. /// </param> private void ParseChunkOffsets(long start, long end) { BoxHeader header; for (long position = start; position < end; position += header.TotalBoxSize) { header = new BoxHeader(file, position); if (header.BoxType == BoxType.Moov) { ParseChunkOffsets( header.HeaderSize + position, header.TotalBoxSize + position); } else if (header.BoxType == BoxType.Moov || header.BoxType == BoxType.Mdia || header.BoxType == BoxType.Minf || header.BoxType == BoxType.Stbl || header.BoxType == BoxType.Trak) { ParseChunkOffsets( header.HeaderSize + position, header.TotalBoxSize + position); } else if (header.BoxType == BoxType.Stco || header.BoxType == BoxType.Co64) { stco_boxes.Add(BoxFactory.CreateBox( file, header)); } else if (header.BoxType == BoxType.Mdat) { mdat_start = position; mdat_end = position + header.TotalBoxSize; } if (header.TotalBoxSize == 0) { break; } } }
/// <summary> /// Parses boxes for a specified range, looking for tags. /// </summary> /// <param name="start"> /// A <see cref="long" /> value specifying the seek position /// at which to start reading. /// </param> /// <param name="end"> /// A <see cref="long" /> value specifying the seek position /// at which to stop reading. /// </param> private void ParseTag(long start, long end) { BoxHeader header; for (long position = start; position < end; position += header.TotalBoxSize) { header = new BoxHeader(file, position); if (header.BoxType == BoxType.Moov || header.BoxType == BoxType.Mdia || header.BoxType == BoxType.Minf || header.BoxType == BoxType.Stbl || header.BoxType == BoxType.Trak) { ParseTag(header.HeaderSize + position, header.TotalBoxSize + position); } else if (udta_box == null && header.BoxType == BoxType.Udta) { udta_box = BoxFactory.CreateBox(file, header) as IsoUserDataBox; } else if (header.BoxType == BoxType.Mdat) { mdat_start = position; mdat_end = position + header.TotalBoxSize; } if (header.TotalBoxSize == 0) { break; } } }