raw_packet.go 923 B

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