Exemple #1
0
        /// <summary>
        ///     Constructs and initializes a new instance of
        ///     <see
        ///         cref="Page" />
        ///     with a specified header and packets.
        /// </summary>
        /// <param name="packets">
        ///     A <see cref="ByteVectorCollection" /> object containing
        ///     packets to use for the new instance.
        /// </param>
        /// <param name="header">
        ///     A <see cref="PageHeader" /> object to use as the header of
        ///     the new instance.
        /// </param>
        /// <exception cref="ArgumentNullException">
        ///     <paramref name="packets" /> is <see langword="null" />.
        /// </exception>
        public Page(ByteVectorCollection packets, PageHeader header)
            : this(header)
        {
            if (packets == null)
            {
                throw new ArgumentNullException(nameof(packets));
            }

            this.packets = new ByteVectorCollection(packets);

            var packet_sizes = new List <int>();

            // Build a page from the list of packets.
            foreach (var v in packets)
            {
                packet_sizes.Add(v.Count);
            }

            header.PacketSizes = packet_sizes.ToArray();
        }
Exemple #2
0
        /// <summary>
        ///     Constructs and initializes a new instance of
        ///     <see
        ///         cref="PageHeader" />
        ///     by copying the values from another
        ///     instance, offsetting the page number and applying new
        ///     flags.
        /// </summary>
        /// <param name="original">
        ///     A <see cref="PageHeader" /> object to copy the values
        ///     from.
        /// </param>
        /// <param name="offset">
        ///     A <see cref="uint" /> value specifying how much to offset
        ///     the page sequence number in the new instance.
        /// </param>
        /// <param name="flags">
        ///     A <see cref="PageFlags" /> value specifying the flags to
        ///     use in the new instance.
        /// </param>
        public PageHeader(PageHeader original, uint offset,
                          PageFlags flags)
        {
            version = original.version;
            Flags   = flags;
            absolute_granular_position =
                original.absolute_granular_position;

            StreamSerialNumber = original.StreamSerialNumber;
            PageSequenceNumber =
                original.PageSequenceNumber + offset;

            Size         = original.Size;
            DataSize     = original.DataSize;
            packet_sizes = new List <int>();

            if (PageSequenceNumber == 0 &&
                (flags & PageFlags.FirstPacketContinued) == 0)
            {
                Flags |= PageFlags.FirstPageOfStream;
            }
        }
Exemple #3
0
 /// <summary>
 ///     Constructs and intializes a new instance of
 ///     <see
 ///         cref="Page" />
 ///     with a specified header and no packets.
 /// </summary>
 /// <param name="header">
 ///     A <see cref="PageHeader" /> object to use as the header of
 ///     the new instance.
 /// </param>
 protected Page(PageHeader header)
 {
     Header  = header;
     packets = new ByteVectorCollection();
 }