Пример #1
0
        public void Track(RtpPacket rtpPacket)
        {
            var receiverReport =
                _receiverReports.GetOrAdd(rtpPacket.SynchronizationSource, k => new RtcpReceiverReportPacket
            {
                SynchronizationSource = (uint)_random.Next()
            });

            var receptionReport = new RtcpReceptionReport();

            receptionReport.SynchronizationSource = rtpPacket.SynchronizationSource;

            // todo: correct rtcp reception report

            if (_senderReports.TryGetValue(rtpPacket.SynchronizationSource, out var senderReport))
            {
                receptionReport.ExtendedHighestSequenceNumberReceived = 0;
                receptionReport.LastSRTimestamp  = (uint)(senderReport.NtpTimestamp >> 16);
                receptionReport.DelaySinceLastSR = 0;
            }

            receptionReport.FractionLost = 0;
            receptionReport.CumulativeNumberOfPacketsLost         = 0;
            receptionReport.ExtendedHighestSequenceNumberReceived = 0;
            receptionReport.InterarrivalJitter = 0;

            receiverReport.ReceptionReports = new List <RtcpReceptionReport>(1)
            {
                receptionReport
            };
        }
Пример #2
0
        private static RtcpReceptionReport ParseRtcpReceptionReport(Span <byte> bytes, ref int idx)
        {
            var receptionReport = new RtcpReceptionReport();

            receptionReport.SynchronizationSource = BinaryPrimitives.ReadUInt32BigEndian(bytes.Slice(idx));
            idx += 4;
            receptionReport.FractionLost = bytes[idx];
            idx += 1;
            receptionReport.CumulativeNumberOfPacketsLost = (uint)(bytes[idx] << 16 | bytes[idx + 1] << 8 | bytes[idx + 2]);
            idx += 3;
            receptionReport.ExtendedHighestSequenceNumberReceived = BinaryPrimitives.ReadUInt32BigEndian(bytes.Slice(idx));
            idx += 4;
            receptionReport.InterarrivalJitter = BinaryPrimitives.ReadInt32BigEndian(bytes.Slice(idx));
            idx += 4;
            receptionReport.LastSRTimestamp = BinaryPrimitives.ReadUInt32BigEndian(bytes.Slice(idx));
            idx += 4;
            receptionReport.DelaySinceLastSR = BinaryPrimitives.ReadUInt32BigEndian(bytes.Slice(idx));
            idx += 4;

            return(receptionReport);
        }