Esempio n. 1
0
        /// <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>
        /// <param name="parents">
        ///     A <see cref="T:List" /> of <see cref="BoxHeader" /> parents.
        /// </param>
        private void ParseTag(long start, long end,
                              List <BoxHeader> parents)
        {
            BoxHeader header;

            for (var position = start;
                 position < end;
                 position += header.TotalBoxSize)
            {
                header = new BoxHeader(file, position);

                if (header.BoxType == BoxType.Moov)
                {
                    ParseTag(header.HeaderSize + position,
                             header.TotalBoxSize + position,
                             AddParent(parents, header));
                }
                else if (header.BoxType == BoxType.Mdia ||
                         header.BoxType == BoxType.Minf ||
                         header.BoxType == BoxType.Stbl ||
                         header.BoxType == BoxType.Trak)
                {
                    ParseTag(header.HeaderSize + position,
                             header.TotalBoxSize + position,
                             AddParent(parents, header));
                }
                else if (header.BoxType == BoxType.Udta)
                {
                    var udtaBox = BoxFactory.CreateBox(file,
                                                       header) as IsoUserDataBox;

                    // Since we can have multiple udta boxes, save the parent for each one
                    var new_parents = AddParent(
                        parents, header);

                    udtaBox.ParentTree = new_parents.ToArray();

                    udta_boxes.Add(udtaBox);
                }
                else if (header.BoxType == BoxType.Mdat)
                {
                    mdat_start      = position;
                    MdatEndPosition = position + header.TotalBoxSize;
                }

                if (header.TotalBoxSize == 0)
                {
                    break;
                }
            }
        }
Esempio n. 2
0
        /// <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 (var 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;
                    MdatEndPosition = position + header.TotalBoxSize;
                }

                if (header.TotalBoxSize == 0)
                {
                    break;
                }
            }
        }
Esempio n. 3
0
        /// <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>
        /// <param name="parents">
        ///     A <see cref="T:List" /> of <see cref="BoxHeader" /> parents.
        /// </param>
        private void ParseTagAndProperties(long start, long end,
                                           IsoHandlerBox handler, List <BoxHeader> parents)
        {
            BoxHeader header;

            for (var position = start;
                 position < end;
                 position += header.TotalBoxSize)
            {
                header = new BoxHeader(file, position);
                var type = header.BoxType;

                if (type == BoxType.Moov)
                {
                    ParseTagAndProperties(header.HeaderSize + position,
                                          header.TotalBoxSize + position,
                                          handler,
                                          AddParent(parents, header));
                }
                else if (type == BoxType.Mdia ||
                         type == BoxType.Minf ||
                         type == BoxType.Stbl ||
                         type == BoxType.Trak)
                {
                    ParseTagAndProperties(
                        header.HeaderSize + position,
                        header.TotalBoxSize + position,
                        handler,
                        AddParent(parents, header));
                }
                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 (MovieHeaderBox == null &&
                         type == BoxType.Mvhd)
                {
                    MovieHeaderBox = BoxFactory.CreateBox(file,
                                                          header, handler) as
                                     IsoMovieHeaderBox;
                }
                else if (type == BoxType.Udta)
                {
                    var udtaBox = BoxFactory.CreateBox(file,
                                                       header, handler) as
                                  IsoUserDataBox;

                    // Since we can have multiple udta boxes, save the parent for each one
                    var new_parents = AddParent(
                        parents, header);

                    udtaBox.ParentTree = new_parents.ToArray();

                    udta_boxes.Add(udtaBox);
                }
                else if (type == BoxType.Mdat)
                {
                    mdat_start      = position;
                    MdatEndPosition = position + header.TotalBoxSize;
                }

                if (header.TotalBoxSize == 0)
                {
                    break;
                }
            }
        }