From 19cf46fb9d6e72237ed346a4c9cc1a0f2fb44d18 Mon Sep 17 00:00:00 2001 From: Woodrow Douglass Date: Tue, 4 Dec 2018 09:11:21 -0500 Subject: [PATCH] Add RTCP Messages *Avoid a type switch in srtp.go *Add support for transport layer nack and slice loss indication messages *Add String() functions for several RTCP packets to aid in debugging *Add support for transparent profile extensions to ReceiverReport messages Relates to #119 --- packet.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/packet.go b/packet.go index e9f28b2..90945f7 100644 --- a/packet.go +++ b/packet.go @@ -2,6 +2,7 @@ package rtp import ( "encoding/binary" + "fmt" "github.com/pkg/errors" ) @@ -47,6 +48,21 @@ const ( csrcLength = 4 ) +// String helps with debugging by printing packet information in a readable way +func (p Packet) String() string { + out := "RTP PACKET:\n" + + out += fmt.Sprintf("\tVersion: %v\n", p.Version) + out += fmt.Sprintf("\tMarker: %v\n", p.Marker) + out += fmt.Sprintf("\tPayload Type: %d\n", p.PayloadType) + out += fmt.Sprintf("\tSequence Number: %d\n", p.SequenceNumber) + out += fmt.Sprintf("\tTimestamp: %d\n", p.Timestamp) + out += fmt.Sprintf("\tSSRC: %d (%x)\n", p.SSRC, p.SSRC) + out += fmt.Sprintf("\tPayload Length: %d\n", len(p.Payload)) + + return out +} + // Unmarshal parses the passed byte slice and stores the result in the Packet this method is called upon func (p *Packet) Unmarshal(rawPacket []byte) error { if len(rawPacket) < headerLength {