Files
webrtc/pkg/rtcp/raw_packet.go
Max Hawkins 5655d151b1 Add rtcp.RawPacket type
This will be returned by Unmarhsal when an unknown type is seen
in the packet stream, avoiding an error and allowing the user to
write their own packet handling code for that type if desired.

Relates to #119
2018-12-04 14:46:33 -05:00

26 lines
520 B
Go

package rtcp
// RawPacket represents an unparsed RTCP packet. It's returned by Unmarshal when
// a packet with an unknown type is encountered.
type RawPacket []byte
// Marshal encodes the packet in binary.
func (r RawPacket) Marshal() ([]byte, error) {
return r, nil
}
// Unmarshal decodes the packet from binary.
func (r *RawPacket) Unmarshal(b []byte) error {
if len(b) < (headerLength) {
return errPacketTooShort
}
*r = b
var h Header
if err := h.Unmarshal(b); err != nil {
return err
}
return nil
}