raw_packet.go 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly>
  2. // SPDX-License-Identifier: MIT
  3. package rtcp
  4. import "fmt"
  5. // RawPacket represents an unparsed RTCP packet. It's returned by Unmarshal when
  6. // a packet with an unknown type is encountered.
  7. type RawPacket []byte
  8. // Marshal encodes the packet in binary.
  9. func (r RawPacket) Marshal() ([]byte, error) {
  10. return r, nil
  11. }
  12. // Unmarshal decodes the packet from binary.
  13. func (r *RawPacket) Unmarshal(b []byte) error {
  14. if len(b) < (headerLength) {
  15. return errPacketTooShort
  16. }
  17. *r = b
  18. var h Header
  19. return h.Unmarshal(b)
  20. }
  21. // Header returns the Header associated with this packet.
  22. func (r RawPacket) Header() Header {
  23. var h Header
  24. if err := h.Unmarshal(r); err != nil {
  25. return Header{}
  26. }
  27. return h
  28. }
  29. // DestinationSSRC returns an array of SSRC values that this packet refers to.
  30. func (r *RawPacket) DestinationSSRC() []uint32 {
  31. return []uint32{}
  32. }
  33. func (r RawPacket) String() string {
  34. out := fmt.Sprintf("RawPacket: %v", ([]byte)(r))
  35. return out
  36. }