Beispiel #1
0
        public RTCPPacket(byte[] packet)
        {
            Header = new RTCPHeader(packet);

            if (BitConverter.IsLittleEndian)
            {
                SenderSyncSource  = NetConvert.DoReverseEndian(BitConverter.ToUInt32(packet, 4));
                NTPTimestamp      = NetConvert.DoReverseEndian(BitConverter.ToUInt64(packet, 8));
                RTPTimestamp      = NetConvert.DoReverseEndian(BitConverter.ToUInt32(packet, 16));
                SenderPacketCount = NetConvert.DoReverseEndian(BitConverter.ToUInt32(packet, 20));
                SenderOctetCount  = NetConvert.DoReverseEndian(BitConverter.ToUInt32(packet, 24));
            }
            else
            {
                SenderSyncSource  = BitConverter.ToUInt32(packet, 4);
                NTPTimestamp      = BitConverter.ToUInt64(packet, 8);
                RTPTimestamp      = BitConverter.ToUInt32(packet, 16);
                SenderPacketCount = BitConverter.ToUInt32(packet, 20);
                SenderOctetCount  = BitConverter.ToUInt32(packet, 24);
            }

            Reports = new byte[packet.Length - RTCPHeader.HEADER_BYTES_LENGTH - SENDERINFO_BYTES_LENGTH];
            Buffer.BlockCopy(packet, RTCPHeader.HEADER_BYTES_LENGTH + SENDERINFO_BYTES_LENGTH, Reports, 0,
                             Reports.Length);
        }
Beispiel #2
0
 public RTCPPacket(uint senderSyncSource, ulong ntpTimestamp, uint rtpTimestamp, uint senderPacketCount, uint senderOctetCount)
 {
     Header            = new RTCPHeader();
     SenderSyncSource  = senderSyncSource;
     NTPTimestamp      = ntpTimestamp;
     RTPTimestamp      = rtpTimestamp;
     SenderPacketCount = senderPacketCount;
     SenderOctetCount  = senderOctetCount;
 }
Beispiel #3
0
            public void GetRTCPHeaderTest()
            {
                Console.WriteLine(System.Reflection.MethodBase.GetCurrentMethod().Name);

                RTCPHeader rtcpHeader = new RTCPHeader();

                byte[] headerBuffer = rtcpHeader.GetHeader(0, 0);

                int byteNum = 1;

                foreach (byte headerByte in headerBuffer)
                {
                    Console.WriteLine(byteNum + ": " + headerByte.ToString("x"));
                    byteNum++;
                }
            }
Beispiel #4
0
            public void RTCPHeaderRoundTripTest()
            {
                Console.WriteLine(System.Reflection.MethodBase.GetCurrentMethod().Name);

                RTCPHeader src = new RTCPHeader();

                byte[]     headerBuffer = src.GetHeader(17, 54443);
                RTCPHeader dst          = new RTCPHeader(headerBuffer);

                Console.WriteLine("Version: " + src.Version + ", " + dst.Version);
                Console.WriteLine("PaddingFlag: " + src.PaddingFlag + ", " + dst.PaddingFlag);
                Console.WriteLine("ReceptionReportCount: " + src.ReceptionReportCount + ", " + dst.ReceptionReportCount);
                Console.WriteLine("PacketType: " + src.PacketType + ", " + dst.PacketType);
                Console.WriteLine("Length: " + src.Length + ", " + dst.Length);

                //Console.WriteLine("Raw Header: " + System.Text.Encoding.ASCII.GetString(headerBuffer, 0, headerBuffer.Length));

                Assert.IsTrue(src.Version == dst.Version, "Version was mismatched.");
                Assert.IsTrue(src.PaddingFlag == dst.PaddingFlag, "PaddingFlag was mismatched.");
                Assert.IsTrue(src.ReceptionReportCount == dst.ReceptionReportCount, "ReceptionReportCount was mismatched.");
                Assert.IsTrue(src.PacketType == dst.PacketType, "PacketType was mismatched.");
                Assert.IsTrue(src.Length == dst.Length, "Length was mismatched.");
            }