示例#1
0
        protected ByteVector Render(bool isHeader)
        {
            ByteVector vector = new ByteVector();

            // add the file identifier -- "APETAGEX"

            vector.Add(FileIdentifier);

            // add the version number -- we always render a 2.000 tag regardless of what
            // the tag originally was.
            vector.Add(ByteVector.FromUInt(2000, false));

            // add the tag size
            vector.Add(ByteVector.FromUInt(tagSize, false));

            // add the item count
            vector.Add(ByteVector.FromUInt(itemCount, false));

            // render and add the flags
            uint flags = 0;

            flags |= (uint)((HeaderPresent ? 1 : 0) << 31);
            // footer is always present
            flags |= (uint)((isHeader ? 1 : 0) << 29);

            vector.Add(ByteVector.FromUInt(flags, false));

            // add the reserved 64bit

            vector.Add(ByteVector.FromLong(0));

            return(vector);
        }
示例#2
0
 public ByteVector Render()
 {
     return(ByteVector.FromUInt(part1, false).Mid(0, 4)
            + ByteVector.FromShort(part2, false).Mid(0, 2)
            + ByteVector.FromShort(part3, false).Mid(0, 2)
            + ByteVector.FromShort(part4, true).Mid(0, 2)
            + ByteVector.FromLong(part5, true).Mid(2, 6));
 }
        private List <ulong> offsets;        //ulong[] offsets;
        #endregion

        #region Private Methods
        private ByteVector UpdateOffsetInternal(long sizeDifference)
        {
            ByteVector output = ByteVector.FromUInt((uint)offsets.Count);

            for (int i = 0; i < offsets.Count; i++)
            {
                offsets[i] = (ulong)((long)offsets[i] + sizeDifference);
                output    += ByteVector.FromLong((long)offsets[i]);
            }

            return(output);
        }
示例#4
0
        public ByteVector Render()
        {
            ByteVector data = new ByteVector();

            // capture patern
            data.Add("OggS");

            // stream structure version
            data.Add(0);

            // header type flag
            byte flags = 0;

            if (firstPacketContinued)
            {
                flags |= 1;
            }
            if (pageSequenceNumber == 0)
            {
                flags |= 2;
            }
            if (lastPageOfStream)
            {
                flags |= 4;
            }

            data.Add(flags);

            // absolute granular position
            data.Add(ByteVector.FromLong(absoluteGranularPosition, false));

            // stream serial number
            data.Add(ByteVector.FromUInt(streamSerialNumber, false));

            // page sequence number
            data.Add(ByteVector.FromUInt((uint)pageSequenceNumber, false));

            // checksum -- this is left empty and should be filled in by the Ogg::Page
            // class
            data.Add(new ByteVector(4, 0));

            // page segment count and page segment table
            ByteVector page_segments = LacingValues;

            data.Add((byte)page_segments.Count);
            data.Add(page_segments);

            return(data);
        }
示例#5
0
        public ByteVector Render()
        {
            // The size is zero because the box header was created not read.
            // Increase the sizes to account for this.
            if (size == 0)
            {
                size       = (uint)(extendedType != null ? 24 : 8);
                largeSize += size;
            }

            // Enlarge for large size if necessary. If large size is in use, the
            // header will be 16 or 32 big as opposed to 8 or 24.
            if ((size == 8 || size == 24) && largeSize > System.UInt32.MaxValue)
            {
                size      += 8;
                largeSize += 8;
            }

            // Get ready to output.
            ByteVector output = new ByteVector();

            // Add the box size and type to the output.
            output += ByteVector.FromUInt((size == 8 || size == 24) ? (uint)largeSize : 1);
            output += boxType;

            // If the box size is 16 or 32, we must have more a large header to
            // append.
            if (size == 16 || size == 32)
            {
                output += ByteVector.FromLong((long)largeSize);
            }

            // The only reason for such a big size is an extended type. Extend!!!
            if (size >= 24)
            {
                output += (extendedType != null) ? extendedType.Mid(0, 16) : new ByteVector(16);
            }

            return(output);
        }