コード例 #1
0
        public IEnumerable <RtcpPacket> GetReportByePackets()
        {
            RtcpReceiverReportPacket receiverReport = CreateReceiverReport();

            yield return(receiverReport);

            RtcpByePacket byeReport = new RtcpByePacket(_senderSyncSourceId);

            yield return(byeReport);
        }
コード例 #2
0
        public IEnumerable <RtcpPacket> GetReportSdesPackets()
        {
            RtcpReceiverReportPacket receiverReport = CreateReceiverReport();

            yield return(receiverReport);

            RtcpSdesReportPacket sdesReport = CreateSdesReport();

            yield return(sdesReport);
        }
コード例 #3
0
        private RtcpReceiverReportPacket CreateReceiverReport()
        {
            int fractionLost;

            if (_rtpStatisticsProvider.PacketsReceivedSinceLastReset == 0)
            {
                fractionLost = 0;
            }
            else
            {
                fractionLost = _rtpStatisticsProvider.PacketsLostSinceLastReset * 256 /
                               _rtpStatisticsProvider.PacketsReceivedSinceLastReset;
            }

            uint lastNtpTimeSenderReportReceived;
            uint delaySinceLastTimeSenderReportReceived;

            if (_rtcpSenderStatisticsProvider.LastTimeReportReceived == DateTime.MinValue)
            {
                lastNtpTimeSenderReportReceived        = 0;
                delaySinceLastTimeSenderReportReceived = 0;
            }
            else
            {
                lastNtpTimeSenderReportReceived =
                    (uint)((_rtcpSenderStatisticsProvider.LastNtpTimeReportReceived >> 16) & uint.MaxValue);

                TimeSpan delta = DateTime.UtcNow - _rtcpSenderStatisticsProvider.LastTimeReportReceived;
                delaySinceLastTimeSenderReportReceived = (uint)delta.TotalSeconds * 65536;
            }

            uint extHighestSequenceNumberReceived = (uint)(_rtpStatisticsProvider.SequenceCycles << 16 |
                                                           _rtpStatisticsProvider.HighestSequenceNumberReceived);

            var rtcpReportBlock = new RtcpReportBlock(_rtpStatisticsProvider.SyncSourceId, fractionLost,
                                                      _rtpStatisticsProvider.CumulativePacketLost, extHighestSequenceNumberReceived, 0,
                                                      lastNtpTimeSenderReportReceived, delaySinceLastTimeSenderReportReceived);

            var receiverReport = new RtcpReceiverReportPacket(_senderSyncSourceId, new[] { rtcpReportBlock });

            _rtpStatisticsProvider.ResetState();

            return(receiverReport);
        }