Esempio n. 1
0
        public static RtpPacket FromBuffer(byte[] buffer, int offset, int?length = null)
        {
            var rtpPacket = new RtpPacket();

            rtpPacket.Header = RtpHeader.FromBuffer(buffer, offset);
            int payloadStartIndex = offset + rtpPacket.Header.Length;
            int payloadLength;

            if (length != null)
            {
                payloadLength = length.Value - payloadStartIndex;
            }
            else
            {
                // Check payload to determine its length.
                switch (rtpPacket.Header.PayloadType.Number)
                {
                default:
                    payloadLength = buffer.Length - payloadStartIndex;
                    break;
                }
            }
            rtpPacket.Payload = new ArraySegment <byte>(buffer, payloadStartIndex, payloadLength);
            return(rtpPacket);
        }
Esempio n. 2
0
        public static RtpHeader FromBuffer(byte[] buffer, int offset)
        {
            var header = new RtpHeader();

            header.Buffer = buffer;
            header.Offset = offset;
            header.Length = 12; // Set minimal header length.

            // Check if Extension Bit is set.
            if (header.HasExtension)
            {
                header.Length += 4;
            }

            // Check CSRC
            header.Length += header.CsrcCount * 4;
            return(header);
        }
Esempio n. 3
0
 public RtpPacket(byte[] buffer, int offset, PayloadType payloadType = null, uint ssrc = 0, ushort sequenceNumber = 0, uint timestamp = 0, bool marker = false, uint?extension = null, uint[] csrc = null)
 {
     Header = new RtpHeader(buffer, offset, payloadType, ssrc, sequenceNumber, timestamp, marker, extension, csrc);
 }