/// <summary> /// Throws an <see cref="ArgumentException"/> if the given <see cref="RtcpReport"/> is null or disposed or does not have the same <see cref="System.Type"/> which is expected as the <see cref="PayloadType"/> implemented. /// </summary> /// <param name="report">The <see cref="RtcpReport"/> to verify</param> internal static void VerifyPayloadType(this RtcpReport report) { if (RtcpPacket.GetImplementationForPayloadType(report.PayloadType) != report.GetType()) { throw new ArgumentException("RtcpReport Implementation does not match type of report."); } }
/// <summary> /// Constructs a PayloadSpecificFeedbackReport instance from an existing RtcpPacket reference. /// Throws a ArgumentNullException if reference is null. /// Throws an ArgumentException if the <see cref="RtcpHeader.PayloadType"/> is not PayloadSpecificFeedbackReport (206) /// </summary> /// <param name="reference">The packet containing the PayloadSpecificFeedbackReport</param> public PayloadSpecificFeedbackReport(RtcpPacket reference, bool shouldDispose = true) : base(reference.Header, reference.Payload, shouldDispose) { if (Header.PayloadType != PayloadType) { throw new System.ArgumentException("Header.PayloadType is not equal to the expected type of 206.", "reference"); } }
static RFC4585() { //Payload type (PT): 8 bits //This is the RTCP packet type that identifies the packet as being //an RTCP FB message. Two values are defined by the IANA: // Name | Value | Brief Description //----------+-------+------------------------------------ // RTPFB | 205 | Transport layer FB message // PSFB | 206 | Payload-specific FB message RtcpPacket.TryMapImplementation(Rtcp.Feedback.TransportLayerFeedbackReport.PayloadType, typeof(Rtcp.Feedback.TransportLayerFeedbackReport)); RtcpPacket.TryMapImplementation(Rtcp.Feedback.PayloadSpecificFeedbackReport.PayloadType, typeof(Rtcp.Feedback.PayloadSpecificFeedbackReport)); }
public void Parse_RtcpByePacketBytes_ReturnsValidPacket() { byte[] byePacketBytes = { 0x80, 0xCB, 0x00, 0x00 }; var segment = new ArraySegment <byte>(byePacketBytes); IEnumerable <RtcpPacket> packets = RtcpPacket.Parse(segment); var byePacket = (RtcpByePacket)packets.First(); Assert.AreEqual(2, byePacket.ProtocolVersion); Assert.AreEqual(false, byePacket.PaddingFlag); Assert.AreEqual(203, byePacket.PayloadType); Assert.AreEqual(0, byePacket.SourceCount); }
/// <summary> /// Constructs a RtcpFeedbackReport instance from an existing RtcpPacket reference. /// Throws a ArgumentNullException if reference is null. /// Throws an ArgumentException if the <see cref="RtcpHeader.PayloadType"/> is not 205 or 206. /// </summary> /// <param name="reference">The packet containing the RtcpFeedbackReport</param> public RtcpFeedbackReport(RtcpPacket reference, bool shouldDispose = true) : base(reference.Header, reference.Payload, shouldDispose) { //Validate PayloadType if (Header.PayloadType < 205 || Header.PayloadType > 206) { throw new ArgumentException("Header.PayloadType is not equal to the expected type.", "reference"); } //Validate Format switch (Format) { case Media.Rtcp.Feedback.RFC4585.FeedbackControlInformationType.Unassigned: throw new InvalidOperationException("PayloadType should be a known FeedbackControlInformationType other than Unassigned."); } }
public string ToTextualConvention(FileFormat?format = null) { try { StringBuilder sb = new StringBuilder(); var ts = Timebase.TimeOfDay.Add(TimeSpan.FromMilliseconds(Offset)); if (IsRtcp) { sb.Append(RtpSend.ToTextualConvention(format ?? Format, RtcpPacket.GetPackets(Blob, Pointer + sizeOf_RD_packet_T, BlobLength - sizeOf_RD_packet_T), ts, Source)); } else { using (var rtp = new Rtp.RtpPacket(Blob, Pointer + sizeOf_RD_packet_T)) sb.Append(RtpSend.ToTextualConvention(format ?? Format, rtp, ts, Source)); } return(sb.ToString()); } catch { throw; } }
public void Parse_SenderReportBytes_ReturnsValidPacket() { byte[] senderReportBytes = { 0x80, 0xC8, 0x00, 0x06, 0x02, 0x75, 0x3B, 0x30, 0xDF, 0x00, 0x01, 0x40, 0x53, 0x13, 0xAD, 0x5B, 0x00, 0x00, 0x17, 0x70, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x04, 0xF7 }; var segment = new ArraySegment <byte>(senderReportBytes); IEnumerable <RtcpPacket> packets = RtcpPacket.Parse(segment); var senderReportPacket = (RtcpSenderReportPacket)packets.First(); Assert.AreEqual(2, senderReportPacket.ProtocolVersion); Assert.AreEqual(false, senderReportPacket.PaddingFlag); Assert.AreEqual(200, senderReportPacket.PayloadType); Assert.AreEqual(0, senderReportPacket.SourceCount); Assert.AreEqual(28, senderReportPacket.Length); Assert.AreEqual(0x2753B30u, senderReportPacket.SyncSourceId); Assert.AreEqual((long)0xDF000140 << 32 | 0x5313AD5Bu, senderReportPacket.NtpTimestamp); }
/// <summary> /// Converts a generic RtcpPacket into a specific RtcpPacket type and forwards it to the /// appropriate method to be processed /// </summary> /// <param name="packet">Generic RtcpPacket</param> /// <param name="ipAddress">IPAddress packet was received from</param> private void ProcessPacket(RtcpPacket packet, IPAddress ipAddress) { switch(packet.PacketType) { case (byte)RtcpPacketType.SR: { ProcessSRPacket(new SrPacket(packet), ipAddress); break; } case (byte)RtcpPacketType.RR: { ProcessRRPacket(new RrPacket(packet), ipAddress); break; } case (byte)RtcpPacketType.SDES: { ProcessSDESPacket(new SdesPacket(packet), ipAddress); break; } case (byte)RtcpPacketType.BYE: { ProcessBYEPacket(new ByePacket(packet), ipAddress); break; } case (byte)RtcpPacketType.APP: { ProcessAPPPacket(new AppPacket(packet)); break; } default: { //eventLog.WriteEntry(string.Format(CultureInfo.CurrentCulture, // Strings.ReceivedAnUnhandledRtcpType, packet.ToString()), EventLogEntryType.Warning, // (int)RtpEL.ID.UnhandledRtcpType); break; } } }