예제 #1
0
 public void Pack(ref byte[] buffer, ref int offset)
 {
     BufferBits.SetUInt16(Profile, buffer, ref offset);
     BufferBits.SetUInt16(Length, buffer, ref offset);
     foreach (var extension in Extension)
     {
         BufferBits.SetUInt32(extension, buffer, ref offset);
     }
 }
예제 #2
0
        public void Pack(ref byte[] buffer, ref int offset)
        {
            BufferBits.Prepare(ref buffer, offset, GetByteLength());

            var bitOffset = 0;

            BufferBits.SetByte(CsrcCount, buffer, offset, ref bitOffset, 4);
            BufferBits.SetBool(HasExtension, buffer, offset, ref bitOffset);
            BufferBits.SetBool(HasPadding, buffer, offset, ref bitOffset);
            BufferBits.SetByte(Version, buffer, ref offset, ref bitOffset, 2);

            bitOffset = 0;
            BufferBits.SetByte(PayloadType, buffer, offset, ref bitOffset, 7);
            BufferBits.SetBool(Marker, buffer, ref offset, ref bitOffset);

            BufferBits.SetUInt16(SequenceNumber, buffer, ref offset);
            BufferBits.SetUInt32(TimeStamp, buffer, ref offset);
            BufferBits.SetUInt32(Ssrc, buffer, ref offset);
            foreach (var csrc in CsrcList.Take(CsrcCount))
            {
                BufferBits.SetUInt32(csrc, buffer, ref offset);
            }

            if (HasExtension)
            {
                Extension.Pack(ref buffer, ref offset);
            }

            if (Payload.Count > 0)
            {
                BufferBits.SetBytes(Payload.ToArray(), buffer, ref offset);
            }

            if (HasPadding && PaddingCount > 0)
            {
                offset += PaddingCount - 1;
                BufferBits.SetByte(PaddingCount, buffer, ref offset);
            }
        }