opus_packet.go 904 B

12345678910111213141516171819202122232425262728293031323334353637
  1. package codecs
  2. // OpusPayloader payloads Opus packets
  3. type OpusPayloader struct{}
  4. // Payload fragments an Opus packet across one or more byte arrays
  5. func (p *OpusPayloader) Payload(mtu uint16, payload []byte) [][]byte {
  6. if payload == nil {
  7. return [][]byte{}
  8. }
  9. out := make([]byte, len(payload))
  10. copy(out, payload)
  11. return [][]byte{out}
  12. }
  13. // OpusPacket represents the Opus header that is stored in the payload of an RTP Packet
  14. type OpusPacket struct {
  15. Payload []byte
  16. audioDepacketizer
  17. }
  18. // Unmarshal parses the passed byte slice and stores the result in the OpusPacket this method is called upon
  19. func (p *OpusPacket) Unmarshal(packet []byte) ([]byte, error) {
  20. if packet == nil {
  21. return nil, errNilPacket
  22. } else if len(packet) == 0 {
  23. return nil, errShortPacket
  24. }
  25. p.Payload = packet
  26. return packet, nil
  27. }
  28. // OpusPartitionHeadChecker is obsolete
  29. type OpusPartitionHeadChecker struct{}