/// <summary> /// Event handler for an RTCP packet being received from the remote party. /// </summary> /// <param name="remoteEndPoint">The end point the packet was received from.</param> /// <param name="buffer">The data received.</param> internal void ControlDataReceived(IPEndPoint remoteEndPoint, byte[] buffer) { try { var rtcpCompoundPacket = new RTCPCompoundPacket(buffer); if (rtcpCompoundPacket != null && rtcpCompoundPacket.SenderReport != null) { if (m_receptionReport == null) { m_receptionReport = new ReceptionReport(rtcpCompoundPacket.SenderReport.SSRC); } m_receptionReport.RtcpSenderReportReceived(rtcpCompoundPacket.SenderReport.NtpTimestamp); var sr = rtcpCompoundPacket.SenderReport; logger.LogDebug($"Received RtcpSenderReport from {remoteEndPoint} pkts {sr.PacketCount} bytes {sr.OctetCount}"); } } catch (Exception excp) { logger.LogError($"Exception RTCPSession.ControlDataReceived. {excp.Message}"); } }
/// <summary> /// Removes the reception report when the remote party indicates no more RTP packets /// for that SSRC will be received by sending an RTCP BYE. /// </summary> /// <param name="ssrc">The SSRC of the reception report being closed. Typically this /// should be the SSRC received in the RTCP BYE.</param> internal void RemoveReceptionReport(uint ssrc) { if (m_receptionReport != null && m_receptionReport.SSRC == ssrc) { logger.LogDebug($"RTCP session removing reception report for remote ssrc {ssrc}."); m_receptionReport = null; } }
/// <summary> /// Event handler for an RTP packet being received by the RTP session. /// Used for measuring transmission statistics. /// </summary> internal void RecordRtpPacketReceived(RTPPacket rtpPacket) { LastActivityAt = DateTime.Now; IsTimedOut = false; PacketsReceivedCount++; OctetsReceivedCount += (uint)rtpPacket.Payload.Length; if (m_receptionReport == null) { m_receptionReport = new ReceptionReport(rtpPacket.Header.SyncSource); } m_receptionReport.RtpPacketReceived(rtpPacket.Header.SequenceNumber, rtpPacket.Header.Timestamp, DateTimeToNtpTimestamp32(DateTime.Now)); }
/// <summary> /// Event handler for an RTP packet being received by the RTP session. /// </summary> internal void RtpPacketReceived(RTPPacket rtpPacket) { RTPLastActivityAt = DateTime.Now; PacketsReceivedCount++; OctetsReceivedCount += (uint)rtpPacket.Payload.Length; if (m_receptionReport == null) { m_receptionReport = new ReceptionReport(rtpPacket.Header.SyncSource); } bool ready = m_receptionReport.RtpPacketReceived(rtpPacket.Header.SequenceNumber, rtpPacket.Header.Timestamp, DateTimeToNtpTimestamp32(DateTime.Now)); if (!m_isClosed && ready == true && m_rtcpReportTimer == null) { // Send the initial RTCP sender report once the first RTP packet arrives. SendReportTimerCallback(null); } }